OK, I’ve got your attention – so now I can tell you why I really do love git .And it’s only partly because I’m stupid. Here’s the backstory…
Some of you know that I love LEGO MINDSTORMS, and some of you know that I enjoy hacking on older computers, and some of you know that I like to get out and work in the yard. What you may not know is I also have this urge to fix stuff that isn’t really broken – like my DNS-323 storage system. It was working perfectly fine backing up all my photos, music, and hosting some git repositories. But it was not running the latest and greatest version of alt-f firmware.
So I backed up all the stuff under my /home directory on the DNS-323. My photos, music, and miscellaneous setup files, double checked that the backup was good, then proceeded to format the drives so I could start fresh. So far so good.
Those of you paying attention will be asking yourselves “Hey, what about the git repositories. He backed those up too, right?” Wrong. They were not in my /home directory. I cleverly stuck them in /var/www/ so they would be in the "right" place.
So long story short the git repos are gone. What happened next is why I love git.
I just happened to have been doing some development with all of the repos that were being hosted on that DNS-323, so all I had to do was:
- Create a new place to hold the repos on the DNS323 - this time under /home/git so I would not forget about them.
- Go back to the original articles I wrote on setting up git and cgit on the Soekris 4501 and create a bunch of empty repos for the ones I clobbered
- For each of the missing repos, go to the corresponding git folder on my development machine and issue "git push --all" followed by "git push --tags"
Bam! All my repos were back the way they were before I was stupid and clobbered them.
When you do your work using git you have a complete replica of the original repository. It's what makes it possible for you to examine history or create new branches offline - which is a huge advantage that anyone using a remotely hosted svn solution will understand. It also means that as long as you have a up to date clone of that repository, you have a backup, and it's less likely that a single failure cripples your development.
And that's why I love git.