I probably don’t need to tell you that you shouldn’t code without having a source control system. In some of my later projects I have used Git to handle my source control. What is great about Git is that it’s a distributed version control system, but it’s also a centralized version control system.
You can use github.com or another service to host your git repositories, but you only get 300 MB if you choose the free account. If you want more space, you have to pay for it. If you are like me you probably have more than 300 MB of source code. So, what are your choices if you don’t want to pay for hosting?
One solution can be to to use Live Mesh to host your repositories. It gives you over 5 GB of space and it’s completely free. If this sounds cool, keep reading on.
I have created 10 steps on how to use Live Mesh as a centralized repository for Git:
First I download Git for Windows from Google Code. The URL is http://code.google.com/p/msysgit/
The version I’m running is Git 22.214.171.124
Then I install the software. I use the default settings (next, next, next)
The next step is to create a Live Mesh account (you can, of course, use your old account). The URL is http://www.mesh.com
I follow the steps on the webpage and finally install the software.
Then I create a folder called Git on my Live Desktop.
And the folder shows up on my local desktop.
Then it’s time to create a local repository. My project is called Time Tracker. I navigate to the folder I want to add to Git and right-click on the folder and chooses Git GUI Here. A dialog pops up and I choose Create New Repository.
Git GUI shows up on the screen.
As you can see from the screenshot, files I don’t want in my repository are shown (like files generated by ReSharper). I need to remove them and this is what I will do in the next step of this guide.
In the folder where I keep my code, a directory called .git shows up. I navigate into that folder and further into the info folder. Then I open the file called exclude in my favorite text editor.
In this file I can add files and folders I don’t want in my repository. The file looks like this:
Then it’s time to add the project to my local git repository. This time I’m going to use the command prompt. I right-click on the Time Tracker project folder and choose ‘Git Bash Here’ and write: ‘git add .’.
The explanation of this command, cut from the help file, is:
“This command adds the current content of new or modified files to the index, thus staging that content for inclusion in the next commit.”
The next step is to commit the files to the repository. That is done like this: ‘git commit –m “The first commit” ’
Ok, so now I have the files in my local repository. It’s time to add them to Live Mesh.
At the command prompt I write git clone --bare . C:/Users/<user>/Desktop/Git/TimeTracker (I’m using Windows Vista).
The –bare keyword I use in the clone command means that I want to create a directory that contains the contents of the .git directory and not the actual workspace.
Now I can work on my local repository and when I want to update the repository in Live Mesh I can simply use this command:
git push C:/Users/<user>/Desktop/Git/TimeTracker master
Changes done in the local repository are now reflected to Live Mesh and I can work on the project on an other computer (as long as Live Mesh and Git are installed) or share the mesh folder with other project members.
Hope you enjoyed this walkthrough of how to use Git with Live Mesh!