CLI vs. GUIs
Although Git is arguably one of the most powerful developer tools available, it’s unlikely to win a user-experience award anytime soon. The official documentation is as thorough as it is cryptic, and the CLI can be quite scary at times.
For this reason, beginners tend to adopt a graphical user interface (GUI) that hides away some of the complexity. However, if you’re still not using the CLI directly, you’re missing out on a lot that Git has to offer.
Visual workflows
There are a few source control workflows that you might think can only be achieved with a GUI, due to their visual nature. However, the Git CLI goes a long way in providing usable text-based interfaces that will handle most day-to-day scenarios.
Viewing differences
The default output of Diff shows deleted lines in red and added lines in green, similar to how a GUI would:
However, it can be difficult to spot the difference in long lines containing small changes. In this case, one option is to use the --word-diff
flag:
A better option is to use a custom pager, which processes the output of Diff/Show/Log and highlights inline changes:
The example above is from diff-highlight, but there are alternatives such as diff-so-fancy, diffr and delta.
Viewing the repository
Most GUI tools have a way of showing all the commits and references in the repository:
You can also achieve something very similar with the CLI:
Admittedly, it can take a little while for your brain to learn to parse that textual output. But once you get used to it, you’ll be surprised by how little you’ll miss the GUI.
Staging partial changes
A GUI can come in handy when you want to pick and choose changes for staging:
Many CLI commands (e.g. Add/Checkout/Reset/Commit/Stash) accept the -p
/--patch
flag, which goes through changes one-by-one and prompts for an action for each:
For an even more powerful option, try the -i
/--interactive
flag:
git add -i
Choosing a GUI
With so many GUIs available, how do you choose the right one? You should avoid tools that try to oversimplify Git concepts (e.g. combine Commit and Push in a single operation). By restricting your access to advanced Git concepts and features, you won’t take advantage of what makes it special.
No GUI will offer the same level of power and flexibility as the CLI, so these tools should be seen as a complement, not as a replacement. As such, it’s a good sign when they provide an easy way to open a terminal.
With time, you’ll find the balance between CLI and GUI that works for you. Let me know in the comments what you use each of these interfaces for!