text post 3/11/2012

Git from the command line or GUI?

My good friend Keenan was asking this question earlier today and I figured he probably was not the only one and that it would be worth outlining the differences here.

My answer is that you should ABSOLUTELY be using git from the command line, always. And here’s why.


Git is all about collaborating and sharing source code, and collaborating is all about working with other developers. Every developer I know or has ever known uses git from the command line, so if you are working with them it will be easier to work together when you are both doing things the same way. In addition, while you need to install a gui, every computer has a terminal by default. This becomes even more important when you are working with remote servers (which you will be often if you are doing web work), and you have to be on the terminal. For this reason, every developer should know enough to be comfortable with bash, git from the command line, and vim.

You should know command line anyway

If you are not a developer or are learning to be one, you should be learning how to become comfortable with the command line anyway. It is an absolutely essential tool in every developer’s toolkit, and you simply not will be able to survive without it. Although you need to spend time learning how it works, trust me, it will pay off in a very big way. As @holman says, bash (and the terminal) is a glue language - unlike ruby or python or clojure, everybody is using it.

The command line shows how your computer really works. It’s like a little look into its guts. And that is awesome to see, and will in the end assist you a lot in understanding how your computer works and how to solve problems using a computer.

Finally, git is a super easy way to use the command line. It couldn’t get easier. You only actually have to know three to five commands to get by with git, and I use those three to five command about 98% of the time that I’m using git. Making yourself familiar with the command line using git is a great entryway into other drugs cool command line things.

Git was written for command line

This might seem obvious, and I bet I’ll get a lot of dissenters weighing in here over anywhere else, but the fact of the matter is that git was intended to be used on the command line. That’s its native environment. Using it through an application is just a hack - it’s taking git out of its natural habitat and saying “why don’t you try to just survive like this instead”. It’s barely even moral. Keep the fish in the water - use git where it was designed to be used, and you will find that life for it and for you will be much happier.

Git GUIs make git more difficult and complicated

Git is simple. It’s just like saving a document. It doesn’t need a gigantic application, and often times the applications will create weird commits, weird branches, and screw up your files and code and you will have no idea what’s happening because they push all the logic behind the curtain. I have seen people using one of the better git apps out there, github for mac, and totally screwing things up time after time. And after I have showed those same people how to use git from the command line, they dropped the app and life became infinitely easier for them.

In addition, by adding a gui to anything, you are compromising power for usability. As you become more advanced, you will find that in addition to the 3-5 simple commands we use 98% of the time, when that 2% arises, git has an incredibly powerful set of tools for dealing with almost any situation you can think of, and guis do not have these.  I’ll give you one example:

You are writing code, about half done with a feature. Your coworker mentions that they made an update that will help you, and just pushed it to github. When you try to pull, it says you must commit your changes before you can pull, but you are not done with your feature or ready to make a commit. With a GUI app, you solve this by making a useless “in progress” commit anyway, pulling, and committing again once its done. With git in its native environment, you run git stash, pull, run git stash apply, fix conficts if there are any, and move on.

It’s faster from the command line.

Let’s face it, something like saving your work should be as quick and easy as possible. Command S, right? Using the command line, it can be like this. Here’s what I do currently to make commits.

Writing code. Hit control + space, terminal slides out (totalterminal), already displaying my git branch (git completion) . Hit “s” - git displays which files have been added, modified, etc, and what branch I’m on. Type “c ‘commit message’” - back to work. If I want to push to github, 'mpush’ pushes to master, then back to work. To pull, 'mpull’. Its super quick to slide out a window from the side, make these changes and see what’s going on, and be done with it. Putting in all the effort of switching to another program and going through multiple views, buttons, and menus to accomplish this will while in the short run perhaps be easier because it’s more familiar. But in the end, using a GUI will slow you down.

tl;dr - Use git from the command line, always. If you are struggling with it, feel more than free to drop me an email and I’d be happy to help you out. But not before you’ve googled your problem, please.