When it comes to version control, everybody is talking about Git these days. But because it has become a standard, it's often adapted blindly - without knowing why exactly Git is superior to other systems like Subversion, Mercurial, or CVS. Even if you're already using Git, I think it's good to understand what makes Git great.
Read on for some hard (and soft) facts about why Git has become so popular.
1. Save Time
Imagine that, every time before moving your mouse, you’d have to wait for 5 seconds. Pretty annoying, right? With version control it’s quite the same – we’re also only talking about a few seconds per command, but it quickly adds up in your work day. Git, however, is lightning fast. Use your time for something more useful than waiting for your version control system to get back to you.
2. Work Offline
What if you want to work while you’re on the move? With a centralized VCS like Subversion or CVS, you’re stranded if you’re not connected to the central repository. With Git, almost everything is possible simply on your local machine: make a commit, browse your project’s complete history, merge or create branches… Git lets you decide where and when you want to work.
3. Undo Mistakes
Sometimes I make mistakes (it was a shocking discovery for me, too!). What I love about Git is that there’s a little “undo” command for almost every situation. Correct your last commit because you forgot to include that small change. Revert a whole commit because that feature isn’t necessary, anymore. And when the going gets tough you can even restore “deleted” commits with the Reflog – because, behind the scenes, Git rarely really deletes anything. This is peace of mind.
If you want to learn how to undo your mistakes with Git, take a look at the free First Aid Kit for Git, a series of short videos that teach you how to save your neck using Git.
4. Sleep Easy
Have you ever smashed a Subversion repository? I have (and I say this with the associated headache still in vivid memory…). With Git, I can be totally confident because every clone that someone on the team has on their machine is a usable backup. Additionally, almost every action in Git only adds data (deleting is very rare). That makes it pretty hard to really screw things up. And this is a good feeling.
5. Make Useful Commits
There are (at least) two problems when throwing milk, ice cream, and a tomato into a blender. First, after switching it on, no one can tell what you actually put in from looking at this mess. And second, you can’t “roll back” the tomato. The same holds true if you commit a bunch of unrelated changes (a little bit of feature A, something from feature B, a nice little bugfix, …). It’s hard for your teammates to understand what happened and they cannot easily roll back feature A if it causes problems. Git helps you to avoid this mess and create granular commits. With its unique “staging area” concept you can determine exactly which changes shall be included in your next commits, even down to single lines. This is where version control starts to be useful.
6. Work in Your Own Way
When working with Git you can use your very own workflow. One that feels good for you. You don’t have to be a code acrobat to qualify for using Git. Of course, you can connect with multiple remote repositories, rebase instead of merge, and work with submodules when you need it. But you can just as easily work with one central remote repository like in Subversion. All the other advantages remain – regardless of your workflow.
7. Don’t Mix Things Up
Separation of concerns is paramount to keeping track of things. While you’re working on feature A, nothing (and no-one) else should be affected by your unfinished code. What if it turns out the feature isn’t necessary anymore? Or if, after 10 commits, you notice that you took the completely wrong approach? Branching is the answer for these problems. And while other version control systems also know branches, Git is the only one to make it work as it should: fast & easy.
8. Go With the Flow
Only dead fish swim with the stream. And sometimes, clever developers do, too. Git is used by more and more well-known companies and Open Source projects: Ruby On Rails, jQuery, Perl, Debian, the Linux Kernel and many more. A large community often is an advantage by itself because an ecosystem evolves around the system. From code hosting platforms like GitHub and GitLab, to GUI tools like Tower all the way to tutorials and documentation: everything you need is already there!
Take Your Git Skills to the Next Level
Git can add tremendous value to your development workflow. But only if you go beyond the basic "commit, pull, push"!
There are lots of free tutorials on Git available - you only have to invest a bit of your time to become a better developer.