I’ve been thinking a lot about git lately. Git is a pretty fabulous distributed source control system. It’s awesome, but it’s also a little complicated. Hopefully, I can convince you that using git is worth it.
Learning git is an investment, don’t get me wrong. If you’re currently using some solution like SVN or Dropbox or (god forbid) nothing to do source control, you’re used to your own workflow. Learning git is going to be a major disruption to that workflow. This disruption will temporarily reduce your productivity.
However, like most changes in workflows, it becomes natural after a short while and afterward, not only will you return to your normal level of productivity, but you’ll exceed what you used to be able to do because git is amazing.
The payoffs for learning git are worth it.
What are the payoffs?
Git makes looks at individual files within a branch as the sum of all of the commits to that file since it was created. That means that selecting individual commits to create, amend, or delete is really easy. In turn, this makes creating new branches to isolate changes easy. Examining commit log history to find out when a change was made, and by whom, is ridiculously easy. Git is also amazingly fast and distributed.
Distributed, eh? Basically, that means that you can create repositories to commit to and branch within on your local machine. There’s no need to involve a server, like with SVN. I always use git when creating a new branch, even if that project will only live on my machine.
All it takes is a little time to learn the basics, and you’re 90% of the way there.
How much time?
Not much at all. Cumulatively, a few hours over a few weeks.
Like with learning most technical skills, the best way out is through. Just start using git. Don’t obsess over online guides or lists of bash aliases or articles on converting from SVN. Just start using it! Whenever you try to do something and can’t figure it out, just Google it.
For example, the first thing you want to do is probably create a new repository. Within 30 seconds of searching online, you’ll find that the command to do this in the Terminal is:
Next you’ll probably want to add some files. Google that.
git add .
git commit -am "Commit message here."
You get the idea. Don’t try and learn something in a vacuum. Wait until you have the opportunity to apply the skills you learn in a real-world application. That way, the knowledge will stick. If you really are the kind of person who needs tutorials, there are a bunch of good ones over here (hat tip to Denys for the link).
Learning the basics of adding files, committing them, branching, and merging is pretty much most of what you need. Oh, and I’d highly recommend using the Terminal if you can. There are good apps out there to manage repositories for you, but if you want to learn git, you might as well learn git.
Finally, I’d be rue not to mention GitHub. All the reasons I’ve outlined above by themselves make using git worth it. When you add GitHub to the equation with the guides GitHub publishes and the community of opens source developers there, the decision to use git should be an easy one.
The hassle in learning a new skill often seems like it’s not worth the dip in productivity. But how many times have you thought that way about some tool, then learnt it, and now can’t imagine life without it? Once you develop an intuitive understanding of git, that’s exactly how you’ll feel.
I’ve been using git my entire career. I can’t imagine not using it.