A common question Git beginners have is:
"Should I learn Git in a GUI or in the command line?"
So let's start by shortly defining Git GUI and Git command line:
- Git CLI: CLI stands for Command Line Interface. You open a terminal, type commands and tell Git what to do. This is the default interface and the one you get when you install Git.
- Git GUI: GUI stands for Graphical User Interface. Git GUIs are programs that offer an interactive Git experience. You often get visualization of the state of your repository, commit history, and branches. Instead of writing your commands in a terminal, you can click on buttons and menu items. Git GUIs can be stand-alone applications like Github Desktop, Sourcetree, and GitKraken; Or they can be a part of a text editor or an Integrated Development Environment (IDE) like Visual Studio Code, Atom, and PyCharm.
Now, back to the question: Which one should you learn?
Learn Git CLI first. Here are 3 reasons why:
Git CLI is the same in all environments and on all machines. As long as you have Git installed, you have access to Git CLI. Same cannot be said of the GUIs. You might not be able to install them due to IT policies or they might not be available for your operating system.
Another benefit of CLI over GUIs is the completeness of the Git experience. All Git features are covered by the CLI. However, not all GUIs cover all Git features.
You are more likely to get help online if you ask a question using Git CLI terminology than using a specific Git GUI terminology. On top of that, most Git GUIs have bad or non-existing documentation.
Git CLI is not perfect though! There are areas where Git GUIs are superior to the CLI.
When it comes to visualization of branches and commit history, Git GUIs offer a more visually pleasing and interactive experience. You can look at the commit history, you can click on each commit and see what has happened in that commit, see who made it and so on. The default output of git log
shown in the terminal can be hard to grasp for a beginner. Luckily, you can make it more visually pleasing and easier to understand. I wrote an article about it.
Another area where Git GUIs have an advantage is in showing diffs. The git diff
shown in the terminal is sometimes hard to understand. I personally prefer a side-by-side diff. I just open my favorite editor, Visual Studio Code, and look at the diff there.
Even with these two minor cons, I still suggest you learn to use Git in the command line first. Make sure you understand the basic concepts: cloning, staging, committing, checking out commits, branches, remotes, merging, and rebasing. Then, if you want to use a Git GUI feel free to do so. Just try not to rely too heavily on it. Sooner or later, you will end up in a tricky situation with Git, and then the command line will be your only remaining friend.
Top comments (8)
To me it comes down to the amount of black magic done by GUIs.
I prefer to use the CLI for write operations because of simplicity — I can easily control what I do, while most GUIs do a lot more than just
commit -m
orpush
.I prefer to use GUIs for read operations because of complexity — they combine commands in a powerful way and get the most out of Git.
To truly understand what Git is or what Git does, though, I’ll never not recommend this amazing guide.
Totally agree. I think GUIs do a very good job in visualizing the status of the repo and history. Far better CLI can.
I am going to take a look at that guide you recommended. I like the idea of explaining Git concepts rather than commands. I think most Git tutorials geared towards beginners are too focused on HOW to do stuff rather than WHY.
I think the answer is "yes", I use GUI for 90% of my git interactions, but let's be real - it's not going to solve 100% of your issues because git is large and complex so it's good to know at least how to do simple things in cli just in case.
I have been using git for 10 years now. CLI for most of it, gitk to look for branches, resets and cherry-picks and complement it with your IDE to look at the diffs. I very rarely use the IDE integration apart from looking at the diffs before commit. No git GUI and SourceTree for me.
You need tig
I learnt git through the command line. When I found things getting repetitive and reading through git diff's and log's became harder, I started using GitKraken and never looked back.
Arguably, but I believe that introduction to git should start not with a CLI or UI. Instead, a person should see a nice visualisation of a git tree to understand what are the commits and branches.
That's not really sustainable though. What happens when the "hard core" Git user is busy, sick or gone? But I hear you, it is nice to have someone to get help from when Git hits the fan! 😁