Git is Awesome
Git is awesome.
Literally. I am in awe of the suite's power, flexibility, elegance, and yet, at the same time, simplicity.
I used to use Subversion, and used to love it, gradually bring more and more of my life under version control (at least, the digital expression of it; wouldn't be great if all aspects of life could be under version control?). But now having used Git for a while, I do not think that I would seriously consider Subversion when starting new projects, and anything that I can migrate over to Git, I eventually will. Git is to Subversion as cell phones are to landlines. Yes, yes, we'll still have the latter around for a long time to come, and we cannot avoid using them in many places, but given a choice, which would you take?
What makes Git so spectacular?
- A lot of pro-Git arguments talk about its distributed repository concept, with a lack of central repository. Sure, that's true. But perhaps you like the single central repository model, or that fits your development context better. Well, there certainly is nothing to stop you using Git that way. But even with this model, multiple secondary repositories (for backup mirrors, for example) would fit quite well, so we would still have a primary repository, but have the flexibility to maintain backup mirrors or even alternate versions of code in different repositories (for example, perhaps a community-contributed codebase meta-branch). Git is explicitly designed to optionally allow for this sort of flexibility and redundancy without any hassle.
-
Anywhere that is reachable from your computer is a potential repository. If you can
ssh,sftp,http, etc. to it, you stick a Git repository on it. Taken in conjunction with the multiple (secondary, or even tertiary) repositories allow for above, this means you can have a remote primary collaborative repository (e.g., "origin"), a remote backup repository in your personal file server at the office as well as another one at home, and maybe even a fourth special repository for experimentation, etc. etc. - Your local repository is self-contained and complete. Which means that, even without a network connection, you have full access to your entire revision history: you can commit, revert, diff, branch, tag, etc. without pause and stutter. When you get back online, you can push your changes through to all the remote repositories, and sync with them.
-
Git branching is almost magical. Checkout a particular branch and the entire source code tree morphs underneath you to reflect the switched branch. Or, if checking out a new branch, nothing appears to have changed, but things have: in either case, you have now been teleported to a parallel universe. It may not rain doughnuts, but it is just as cool.
Make some changes, minor or major, break things, fix things, test things, break them, fix them again to your heart's content, all in the knowledge that the code base of the previous branch is totally isolated and safe. When you are ready, commit the changes and then checkout the previous branch again. Seamlessly and instantaneously, you are again teleported, but this time back to the original universal: with no muss or fuss, the previous code base appears underneath you with no sign that you ever left it. Merge the changes in from the previous branch and it is like you never left in the first place.
Ok, so branches are nothing new. But the way that Git does it so slick: issue a "
git checkout branchname" and the entire source tree instantly morphs in-situ. No need to change directories, etc. Subversion's way of doing branches worked fine enough, but I always found it a little bit of a "big step" to take, so much so that I often worked on the trunk code for many things, and, since I commit often, it meant that it was not unusual for the trunk code to be broken for long periods of time. Branching in Git is so simple, easy and slick, that I do it very frequently, and it makes it very easy to isolate specific parts of the code base for extensive work without breaking the anything in the primary trunk. I see it like being able to perform major open-heart surgery on a someone without knocking them out or hurting then or even disrupting their day-to-day life in the slightest. -
Creating a Git project is easy: "
git init".That's it---you know have a fully functioning repository in your current directory.
We all know what a palaver it is with Subversion: log into the remote server, create the repository there, assign permissions if necessary, log back to your development machine, import the code base from the original directory into the repository, delete the original directory, checkout your working copy from the repository .... whew, it was tiring just typing out all those steps. I don't know about you, but all these steps meant that I had a certain reluctance in opening up a new repository under Subversion. Which resulted in code either being shoehorned into existing projects where the did not belong, or, worse, simply being stuck on a temporary directory on my local computer, until it had developed sufficient critical mass to merit the work in setting up the repository.
With Git, I often create a local repository before even typing a single line of code, giving me full versioning control from the very beginning. And given that I can mirror and push changes to repositories anywhere using the "
ssh" protocol, I also can backup the project to a remote location from the very beginning as well ... without having to go through the hassle of setting up a full-fledged remotely served repository. Of course, when the code has come together enough to be "born", then I can create and push the changes through to agitosis-managed server. - Git is fast, fast, fast, fast. I'm sure you heard this before, but it really has to be experienced to be believed. Several of the phylogenetic projects that I have under Git version control have MCMC tree data files that run into the multiple gigs. The initial commit and push of those files does take a long while ... but now everything is sitting in the repositories in packed form, everything is blazing fast, even if we were to clone the entire repositories from scrach.
feed
Post new comment