Free Your Git – Make Better Use of the Terminal

Given the robust nature of modern IDEs such as VSCode, the JetBrains applications as well as GUI clients such as GitHub Desktop, developers may be tempted to use their built-in Git version control features. However, doing so sacrifices the expressivity and flexibility achieved by keeping your Git commands in the terminal.

Intentional Usage

The first main advantage of using Git in the terminal is the fine-grained control the user has over how they are interacting with version control. We know that git add . is a bad Git habit to form, but thankfully we also have access to git add -p. This command allows us to choose whether to “patch” code to stage in “hunks” and gives us a variety of commands to work with.

I’d say about 99% of the time, I only use the first three commands: y, n, and q. The first adds a hunk, n does not add the hunk, and q says do not add this and all other hunks (this “quits” out of the git add process). I find git add -p useful for carefully reviewing the code that I want to commit and often find small segments of code that I want to remove or clean up before committing. Additionally, git add -p offers a bunch of other options (besides, y, n, and q) that are always available if you find yourself ever needing greater add flexibility.

Additionally, the same benefits can be found in the git log and git checkout commands (as well as many others!). Use git log to view previous commit hashes and then go to those commit states using git checkout <hash>. I find this also helps give me a clearer picture of the code changes and a more holistic view of commits to date. 

Reduced IDE Reliance

Making your Git interactions terminal native also allows consistent use across multiple systems and environments as well as helping to reduce one’s reliance on bloated IDEs. While great projects such as VSCodium exist, I believe they’re best used as a stepping stone to terminal native development. Using Git alongside Vim or Neovim is an incredibly powerful and smooth development experience.

I frequently use Git to check my current branch and altered files with git status or to “clear away” local changes with git stash while trying something new (and always being able to recover those changes with git stash pop). In this way, and in conjunction with many more Git commands, I can always use Git and Vim in a seamless, convenient, and consistent manner.

Streamlined Git Experience

While one benefit of utilizing Git at the command line is a deeper understanding of the raw commands as well as their various optional flags, it is helpful to reduce verbosity for frequent tasks. This streamlines the experience to make programming more enjoyable.

I do this through heavy use of aliases. For example, two commands I frequently use are git add -p and git commit -m. Instead of typing these out every time, I use gapa and gcmsg respectively. While this may seem like a small optimization, it is a huge developer experience win. I did not learn all the aliases at one time, but slowly added more as I found the need for them, and now I almost exclusively use aliases to interact with Git. One more note: your favorite terminal might come with predefined Git aliases, so check for those before going and creating your own!

Git as an Experience

Learning to use Git at the command line improves Git understanding and expressivity, reduces IDE reliance, and provides a more enjoyable developer experience. Because of these benefits, I’d encourage moving your Git interactions out of VSCode/JetBrains, etc., and into the terminal. Ultimately, I hope integrating this change brings you one step closer to a more personalized and satisfying developer experience! 


Join the conversation

Your email address will not be published. Required fields are marked *