Git for the Locals

“This is a local shop for local people, we want no trouble here!”

— Edward, The League of Gentlemen

I’m normally quite cautious when it comes to IT novelties like new frameworks, new methodologies and similar, especially when it feels like they’re over-hyped. Especially nowadays, it is sometimes very hard to tell whether something new is over-hyped or really a Good Thing™ without spending some time looking into it. And especially nowadays, finding the time to look into something new can be a real challange.

I deliberately didn’t look into Git properly since it went “mainstream” (maybe I shouldn’t use this word), but when this tutorial came out I couldn’t resist. Sure, I knew Git was an amazingly fast distributed version control system, that GitHub offered free accounts, that all the cool guys were slowly starting to use it in place of Subversion, etc. etc.

What I didn’t realize though, that the most obvious advantage of this DVCS was the fact that it was distributed, i.e., it didn’t need a centralized server.

Let me repeat this: Git doesn’t need a centralized server.

Really.h3. …But it’s not user-friendly!

If you’re a Windows user and you used Subversion before, chances are that you got accustomed to TortoiseSVN, too. TortoiseSVN is — in a way — a nice graphical fron-end to SVN which provides seamless Windows Explorer integration.
Git doesn’t have anything like that yet. There’s something in the works, sure, but nothing really comparable to TortoiseSVN. Therefore, you are kindly suggested to get on and use the command line for all your git stuff.

Oh well, I personally love using command line interfaces for certain tasks, event if I spend more time on Windows than on any other OS and well, the DOS prompt is no way near to bash & Co.

For the lazy gits Windows users, MSysGit is the answer to all your problems. Officially you have to install Cygwin and all its crap to be able to use Git on Windows. Not that Cygwin is bad, but I personally don’t like the extra layer it creates between you and an OS symulation which is not really what’s on your machine.It would be great if you could get all the Bash goodies natively, without the hassle.

that’s basically what you get for free when you install MSysGit: the best (to date) version of Bash you could possibly dream of for Windows, along with a few handy Gnu tools and of course all git commands.
In a few click, you’ll be able to use Git (and Bash!) right away: no tricks, no hassle, no kidding.

And stop moaning about the command line not being user friendly. You want a new repository anywhere? Just type in the following:

git init
git add .
git commit

This will create your new repository in the current directory, add all your files and filders recursively, and perform the initial commit. What’s so hard in this? Nothing. And it’s faster than SVN, for sure.

Are you local?

“Being local” has its own advantages: you know where you stand, you know what to expect, you don’t depend on other people. What I didn’t fully realize about Git is that it can be a 100% local repository.

The three Git commands I mentioned earlier can be used to create a repository there, exactly where you are: not on a server far, far away.
Let’s see what this means:

  1. You don’t need an Internet connection anymore to use a VCS
  2. You don’t get a .svn folder in every damn directory of your project, with a load of crappy files in it.
  3. You get only a .git folder at top level, and that’s where your repository actually is. Granted, there are going to be quite a few files in there, but they’re not going to be scattered all over the place
  4. You can physically copy your repository anywhere and still use it
  5. You don’t need to signup to GitHub for an account, if you only want your own VCS

OK, this is an extreme scenario, but sometimes you may want your own local repository for your stuff. You may want a place to version your documents, or a place to version your own little pet programming project nobody knows about.
With Git, you can get all the advantages of a VCS (and an incredibly fast VCS) without having to setup any server infrastructure: just install Git on your machine, and you’re done. No server processes, no hassle.

Don’t connect, synchronize

All the information your repository needs is stored in that little .git folder, nowhere else. You can copy your files and that folder, and you’ll still get your repository back wherever you are. Maybe you can zip it before copying it, and then unzip it where you need a VCS, event.

I tried using some synchronization utilities like SyncToy or RoboCopy on Windows to keep my files synchronized on multiple computers: it all started off from the fact that I can’t use SSH at work, so I wouldn’t be able to push my commits back to a central repository online like GitHub.

So here’s what I did:

  1. I setup a local repository for my project on a local folder at work.
  2. I started working on my project, did a few commits.
  3. After performing the last commit for the day (you are encouraged to commit often by Git, really), I synchronized that folder with my USB key, via SyncToy.
  4. Back at home, I used SyncToy again to synchronize my files (including the repository) between the USB key and my home computer.
  5. Performing a git status showed that some files have been modified (all of them, actually): that’s because Git detected that they weren’t the same files which were committed, presumably because of different timestamps etc.
  6. All I did was a git reset --hard to get exactly the same files I committed at work, with absolutely no information loss.

Isn’t it a bad thing to move your git folder back and forth and let another program to synchronize files within it? Maybe, but it seems to work so far. A safer option, in this case, may be zipping the folder before synchronizing it, just to be sure.


Git can do much more than this. Git offers some really interesting branching features, for example, which I didn’t mention in this article, of course, like several dozens of other commands. What I tried to point out was that Git can be used by anyone, as a fast, simple and very effective private local repository. In case you need one, that is (if you are really local).