08 May 2008 ~ 7 Comments

Yeah, just call me a git

I have started using git for most of my projects. It started as a way for me to continue working with my SVN repositories when I was offline, but as I got more familiar with the application I found I was choosing it over svn.

Why choose it over svn? Because I truly believe that if you are not versioning your code, you shouldn’t be writing code. Why don’t people use versioning systems? Because they are hard to work with and they get in they way. Having to go setup repositories and such can be a major pain. Git is simple. After installing git, CD to the directory of your project and type `git init`. Thats it. You are now ready to start writing code and making commits. Want to share your code with someone? Just zip up the directory and send it to them. Your single .git folder that is at the root of your project contains all the information they need to checkout the history of your work. Don’t want to share your history? Don’t send the .git directory with it :)

Git is a distributed version control system. What does that mean? There does not have to be a single central repository. Any single users copy can be cloned and published and shared on a network sever and accessed via many protocols.

What prompted me to write this post was actually this article on useful git utilities. My primary interaction with git is via the command line and sometimes I dont remember all the options that are available. Using this bash script will allow you to get auto completion for all the git commands. Nice! The trick is to just save that bash file to your home directory and then source it into your path. On the mac, you can edit your .profile file to add the line `source ~/git-completion.bash` (don’t put in the `’s though).

Go on now, get your Git on!

7 Responses to “Yeah, just call me a git”

  1. Ben Nadel 8 May 2008 at 10:00 am Permalink

    That sounds pretty awesome. I have heard Peter Bell talk a lot about Git lately, but didn’t really know what it was. Looks like its really easy to implement.

  2. Justin Carter 8 May 2008 at 11:41 am Permalink

    It does sound pretty cool. The only problem I have with SVN is the .svn folders which mean doing anything with your repository folder (e.g. backing it up, copying a few folders) is slightly annoying because you really need to do an export on it.

    I could google a couple of questions, but perhaps for the benefit of others as well…:
    - Is there an Eclipse plugin for Git (or do you even need one? For arguments sake, I prefer not to use the command line.)
    - Because it is distributed, is there some method to allow for replication of changes so that all users can always see everything that has been committed?

    Thanks for the intro/summary :)

  3. Simeon 8 May 2008 at 12:03 pm Permalink

    @ben Yeah it is cool. I think I may have put git in peters ear :) We were chatting on IM about it.

    @justin Yeah there is an eclipse plugin, its pretty raw and you have to compile it yourself (although I have provided the one I compiled to a couple friends) but it has nice history tracking and all the commands we have come to love in SVN.

    It is distributed so perhaps I should mention the workflow. Your buddy says hey I am working on this cool project the url is … git://github.com/simb/flexrestauth.git. So you jump to you your project folder and run `git clone git://github.com/simb/flexrestauth.git`. Now what that actually gives you is a folder called flexrestauth that has all the code for the project in it. So you go on about building stuff you and you make commits against that. Then when you are ready to send your changes back up so the world can see them you run `git push` to send your changes up to the repo. You can use `git pull` to pull other peoples changes from the repository. Cool huh?

    So another feature that I really like about Git is that I can make commits, test and rollback my code without messing up what the main repo has. If I head down a path I can make frequent commits (good practice) but not have to worry that a commit is a feature complete state. Then push those changes all up when I am done.

    If you ask someone who knows git, they will tell you its real strength is in branching… but I suppose that is a topic for another blog post.

  4. Justin Carter 8 May 2008 at 3:16 pm Permalink

    Sounds great :) I wondered what the hype was about, but now I can definitely see some advantages, thanks Simeon.

  5. Andrei 9 May 2008 at 4:38 am Permalink

    I’ve been using git for a while now, and one thing that’s a huge plus for me is the speed. Checking repo history, doing diffs between revisions, everything is just instant. About two days ago I had to go through some code in a svn repo and everything just felt painfully slow.

    If you’re using git from the commandline you might want to check out these aliases ( http://github.com/relevance/etc/tree/master/bash/git.sh ). I’m lazy and anything that helps me type less is awesome in my book :D

  6. Nathan Mische 9 May 2008 at 6:22 am Permalink

    I’d like to see a post on branching in Git. Does it track the history of all of branching operations? I’ve been using Perforce for the past year and that is one thing I really liked about that SCM system.

  7. Simeon 9 May 2008 at 7:44 am Permalink

    @Andrei I suppose once I am comfortable with all the commands the shortcuts will be super helpful. For right now I actually like seeing the options available using the bash completions. Thanks for the tip!

    @Nathan Yes all of the history is tracked. The eclipse plugin even draws history lines so you can see where stuff comes from which is cool. I could try to write up something on Branching, but most of my info would just come from this great article here: http://lwn.net/Articles/210045/ I had to use perforce on a project recently, and I have to say that I am a big fan of the branch merge model of git over the checkout and lock model that perforce uses.


Leave a Reply

PHVsPjxsaT48c3Ryb25nPndvb19hYm91dDwvc3Ryb25nPiAtIEhpISBNeSBuYW1lIGlzIFNpbWVvbiBCYXRlbWFuIGFuZCBJIGFtIGEgd2ViIGF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