Fun with Decentralised Version Control

One thing Windows does better than Ubuntu on my Alienware M17x is allow
me to use the low power mode on the laptop, which is perfect when
flying.

Once I had set up a simple development environment on my
Windows partition, I needed a way to be able to work on my Coldfusion
code, but not lose any of my source control history. This is where the
power of Git became so very useful.

Since
each Git local repository is a full Git repository in it's own right,
and any Git repository can pull from any Git repository, I did the
following:

While in Ubuntu, plugged in my USB key stick

  1. Opened up a terminal at my usb stick
  2. Cloned my local git repository to the USB Stick
    git clone /home/mark/wwwroot/coldspring ./
  3. Rebooted into Windows
  4. Opened a Cygwin terminal (Yeah, I use Cygwin in Windows, as I hate the Windows terminal)
  5. Cloned the repository on my USB stick to my C: drive
    git clone /cygdrive/g/coldspring ./

I
probably could have made this pathway shorter, but I wanted a way to
backup to an external device in case something went horribly wrong with
the RAID1 hard drives in my laptop.  However, I now had a copy of my Git
repository in my Windows partition, ready to use, with my full
repository commit history.

Once I had got off the plane, and got
back to doing work on my Ubuntu partition again, I needed  to move the
commits in the repository in my Windows partition back to my Ubuntu
partition.

This is now very easy, again, due to the distributed
nature of Git, and the fact that any repository can pull from any
repository. To return all my commit history to my Ubuntu partition,
where I do my main development, I did the following:

  1. Log into my Windows partition
  2. Go to the repository on my flash drive, and pull from the Git repository on my windows hard drive.
    git pull /cygdrive/c/wwwroot/coldspring
  3. Boot back into my Ubuntu partition
  4. Open a terminal in my source folder for Coldspring 2, and pull from the Git repository on my Flash Drive (/media/corsair).
    git pull /media/corsair
  5. Voila – my commit history is intact, and all the changes I made on my Windows partition are on my Ubuntu partition.

That's just how amazingly flexible Git is.  Try and do that on SVN with no Internet connection ;o)

Leave a Comment

Comments

  • Luis Majano | September 8, 2010

    Yes I have to agree with you Mark, I am loving git, it has its quirks and differences and coming from a full SVN background I am still adjusting, but I can honestly say the best way is to just throw yourself into the fire and learn something new! Don’t be afraid of change.

  • Andrew Scott | September 17, 2010

    Having been in the world of Eclispe and SVN, i still don;t see the power of GIT?

    If you want a local repsoitory, then ask eclispe to collect the changes for as many days you want.

    Unless I am missing something, the final merging of code is in GIT is still just as painfull as if you were doing it in SVN.

  • Mark | September 18, 2010

    @Andrew – I think you haven’t seen the light because you haven’t tried it yet ;o) There are so many advantages over SVN it’s a longer list than I can write in a comment.

    If you are tracking changes locally… how do you branch with Eclipse history? Or merge that branch? How do you stash local changes so you can switch out to do other work? How do you get at the work of another developer sitting next to you without having to go through creating SVN branches on your remote repository… the list goes on and on.

  • Andrew Scott | September 18, 2010

    Mark, you might be right. I haven’t given it a chance.

    However, I was very largely put of by the fact that for me to run GIT I am forced to install a 3rd pary application called cygwin, just because the developers have strong hooks into *nix API.

    That is enough for me to say nope not yet.

    As far as all those benefits, yes I can see advantages to them. But I have no problems switching code bases when I need to work on a branch or trunk in SVN now. The downside to SVN is that I may loose any changes not in SVN, which I think is a benefit to GIT.

    but how many people actually work in this way to begin with, to many people still don’t even use SVN to its full advantages either.

  • Bob Chesley | September 30, 2010

    I liked Luis’s comment about jumping into the fire! I recently switched from SVN also and liking git very much. Just found Scott Chacon’s concise comparison at http://whygitisbetterthanx.com in defense of git (nicely done).