Juri Goes GIT - First Steps

Yes, I'm going "git" ;). An inherent part of structured, well organized working is to have your stuff under version control (1st point on the Joel Test). I remember when I first got in touch with version control, the first year at the university and I was impressed. Cool I thought, a central repo, easy collaboration, change history etc. And still, I saw many students continuing to send code files over mail... Since that, a lot changed and version control became self-evident in software development.

Recently distributed version control systems became more popular. Actually they're now around already for a while and yes I know, I'm late to give them a first change only now, but you know... time is rare ;). Anyway, I was already curious to give it a try for a while, so I decided to dedicate a couple of hours to setup git repositories for my "prototyping" stuff and document my first steps here for the late-adopters out there as myself. With "prototyping" stuff I mean my code trials, tech experiments and so on. Till now I simply hosted them inside a folder on Dropbox which automatically gives you basic versioning (30 days back), but it is never as convenient as a fully functional SCM system.

Tools

Here are some tools you may use to install git.
Mac OSX:
Windows

Installation and Configuration

Mac OSX
I downloaded and installed git through MacPorts (article here). Once that process finishes, just launch your terminal and type "git".

Windows
For Windows I chose the msysgit which is the most cited one on the web. The installation process is quite straightforward, just go to their homepage on msysgit.googlecode.com and download the latest version. It's an installer, so launch and click through the install wizard.

Creating the First Repo - Dropbox Comes To Help

There are some public and free available repositories which support git, however, for my small homegrown demos, trials etc, I'll make use of Dropbox as my remote repository host. Here are the basic steps to get started. The output below shows the OSX shell, but the commands are the same under Windows. You just need to right-click on the desired folder and click "Open git bash" (or similar).

I had already a folder on my local system called "prototyping" where all my stuff I want to put under version control resides. In the terminal I navigate to that folder.
JurisMacBookPro:~ Juri$ cd ~/programming/prototyping

Then I initialize a git repository and add the content to it
JurisMacBookPro:prototyping Juri$ git init
JurisMacBookPro:prototyping Juri$ git add .
JurisMacBookPro:prototyping Juri$ git commit -a -m "Initial commit"

Once that is done, your local repository is set up. Now it comes to pushing it to the "remote" Dropbox host. For that purpose I create a folder "gitrepos" on my Dropbox. Then I clone my local repo I just set up to the new remote location:
JurisMacBookPro:prototyping Juri$ git clone --bare . ~/Dropbox/gitrepos/prototyping.git

Furthermore an alias has to be defined:
JurisMacBookPro:prototyping Juri$ git remote add prototyping ~/Dropbox/gitrepos/prototyping.git
It's done. On another workstation (or another person you'd like to share the repo with) can now clone your repository
git clone ~/Dropbox/gitrepos/prototyping.git
git remote add prototyping ~/Dropbox/gitrepos/prototyping.git
Of course the repository needs to be either placed on your public Dropbox folder or it must be shared with the desired user.
Note, the same might also work by using simple SVN repositories instead of Git. I didn't try it, but nothing comes to my mind why that shouldn't work the same.

Cheat Sheet

To start, it is nice to have a cheat sheet in place to easily remember the commands. Here's the one on the git-scm page: http://zrusin.blogspot.com/2007/09/git-cheat-sheet.html
Another one I found a couple of days ago is this one taken from http://panela.blog-city.com.
Original image here

References and Useful Links

Git for SVN users: http://git-scm.com/course/svn.html
Using git with Dropbox: http://blog.rogeriopvl.com/archives/using-git-with-dropbox/
Get Dropbox account with 250MB storage bonus: *here*
Git Main Website: http://git-scm.com/
Kindle

Comments

0

Your ad here?