Git Tricks

Git is one of the most useful tools in my programming toolbox besides the compiler itself. Sure, there are holy wars over which version control system is best (Mercurial, anyone?), but if you’re coming from CVS or Subversion, Git is a huge improvement. Or will be, once you get over the learning curve. I highly recommend Pro Git as a way to become fluent in Git.

If you already use Git, however, you might be wondering how to make it more useful…

git add

Yesterday, I was trying to explain git add and git commit to someone, and hit upon these very clear ways (IMHO) of explaining them:

  • git add adds changes to the next commit
  • git commit saves any added changes to the (local) repository

Why is this particularly clear? It eliminates any notion of “tracked files”.1 You use add whenever you want to record changes in your version history, whether files are new or not.