Thursday, August 28, 2008

Me lovin Git

As I stated previously, I am sold on DVCS, and today it just got better.

I came across a situation where I needed to share highly experimental code with a teammate. There was no way I could check this code into our normal repo, so what first pops into your head: email (strongbad style). You've been here and don't pretend you haven't used email. Oh yes the wonderful land of emailing around jar or zip files repeatedly.

Emailing source code around stopped today. Instead I got on the phone with Ron Alleva who helped walk me through the simple git commands to create my own local master repo. It was so simple it was ridiculous.

Here are the steps to create and share hack code in minutes

  1. install git
  2. cd to the folder you wish to share
  3. run git init
  4. run git add .
  5. run git commit -a
  6. Have your teammate clone it by running git clone ssh://user@host/path/to/repo.git/
Ironically after my teammate first cloned it and tested the code it failed because of a recent change I made. So I made the fix, committed it to my local repo, and he was able to git pull those changes. Also, if he makes any changes we can share them easily as well by him using git push.

6 comments:

Anonymous said...

Egads on passing source through email. GIT is enabling a local repository and basically branching which has existed in CVS, Subversion, etc. for years. A typical practice is creating a branch in the repository and have a team member check out the branch. Any reason why you were unable to go down this path for your environment?

jlorenzen said...

Definitely possible but there were many reasons at play. #1 was I was looking for a good excuse to use a DVCS. #2 I emphasized this was experimental code and it really didn't need a home in our teams svn. #3 It has all the benefits of DVCS such as my teammate being able to check in radical changes locally in his clone without affecting me and us being able to share the best of what we have. #4 From what I read and experienced yesterday branching and merging is much easier in DVCS such as git.

Ronnie76er said...

From what I've been able to tell in my short dealings with git, is that the branching/merging ability is really what sets it head and sholders above svn/cvs. Branching, when you get used to using in git (or mercurial, or bzr) takes on a different meaning entirely when you use it within these tools.

Instantly you can create branches for your experimental code, work on them (with histories of reversions locally...however often you check in), and then either get rid of it when your done or merge it back in.

Anonymous said...

I wonder, have you used any other distributed vcs or is git the first one you tried?

Anonymous said...

I've used Hg (Mercurial) a bit too, and it is slightly simpler for this kind of workflow, specifically because you can easily launch a Hg server (temporarily) to allow the other end to pull/push from/to your local repo.

Carraig Duibh said...

Good readingg this post