My Git workflow

I first attempted to use Git almost a year ago. I tried to use it as a kind of rsync’er between computers for my personal projects+data folder. It didn’t work too well: I think it was primarily built with the idea of versioning and syncing source files, not thousands of WAV sample files scattered around thousands of nested folders. So I left “Start using Git” in my to-do list and almost forgot about it.

Recently I was about to start a project where I didn’t know quite well what direction it was going to take. So I was there, experimenting and hacking code here and there while investigating where would it bring us, when I realised that I would like to have a snapshot of the code at that point, before continuing with the next part. The classic solution would have been to make a .zip of the code folder, or a copy of the folder in the above directory, and continue. But if you want to compare between versions, manually calling diff between file versions is cumbersome. I didn’t want to add the code to the subversion repository because it was by no means ready yet for anything. So I though: why don’t I use git for this?

First steps were a bit uncertain, but I quickly developed a simple yet effective command line technique. Yeah, no IDE plug-in whatsoever, I am just using a bash terminal. It works pretty much like this:

  • code code code
  • looks good! let’s store this…
  • git add file1.cpp file2.cpp ………. or git add . for adding all changed files to the commit
  • git commit (so that I can enter more than one line of commit message, in the editor that shows up) or git commit -m ‘commit message’ for one liners.

Sometimes, when I want to see what has changed, I use gitk. It is admittedly ugly but once you get it, it’s nicer than reading plain diff output in a terminal screen. Specially because you can navigate between changes, instead of having to manually invoke diff for each file you want to compare.

At a certain point I wanted to make a huge code change, so I made a new branch. Actually, I haven’t gone back to the other branch since then, but it’s good to know it’s there in case I want to see how the code is in that totally incompatible code and class-wise approach to the problem.

Probably one of the things I like more is that everything is lightning fast. Since the repository is stored locally, there is no more waiting for commits to finish or contacting the server for getting a diff. Even if your Subversion server is in your local network, it will never beat the experience of a localhost, direct disk access based repository. This way, one doesn’t get distracted with the check in/commit process; it becomes an almost automatic action so the mind can be focused in the real problem: the code!

If you’re an advanced git user, you might have already realised that I am only using a very reduced set of git features. Whether that’s sad or not, I leave it up to you; I just wanted to highlight the notion that although git is generally used (or was designed) for huge projects with lots of collaborators branching and merging intensively and all that, it is actually very good for producing what I call code sketches, and it doesn’t need to be used by several users with all the clone, pull, push and rest of single-worded verbs paraphernalia to enjoy its power.

Please don’t understand this post as a subversion sucks, use git square-headed litany, but rather as a friendly git could be quite useful, if you have some spare time you might consider having a look at it suggestion from a long-time Subversion user who knows Git is intimidating but worth the effort to learn :D

ie6 for Android

Comments

  • I’m sure you already knew I was about to say something… indeed, you’re right!

    I completely agree with you about git, but one piece of advice: Do not , repeat with me, never, try to mess git (or other DCVS) with subversion. The possibility sounds good at the beginning, but after a few branches, playing, and so on, just when you are about to commit everything back to subversion… it may fail! (because the DCVS’s structure doesn’t get along with non-DCVS’s)

    In my experience, if you are going to work on a very big project, under a unix environment, and mostly alone… git is great. But, if you need to share code with your work mates, and your work mates are not as into as you in that kind of stuff… Mercurial is far easier to use and start with.

    Cheeers!

  • There’s nothing wrong with you saying something! In fact the reason for me writing this is to get an idea of how ‘real’ people use git :D

    I hadn’t thought of mixing subversion + git. I only tried once the process of importing from svn to git. It worked quite well, actually. But I didn’t try the reverse direction :D Good to know it’s got problems, thanks!

  • We had used cvs, subversion, mercurial and now we’re using git at work. The main reason that make us to move to git its github, its great to work in your own fork of something and send back to the original code if you want.

    We’re using git with clone, pull, push commands to have something like subversion and keep synchronized between devs. To do this we have something like a centralized repository in a server so we get the advantages of two worlds.

    But as pplux said, mercurial seems easier to understand and a little bit more elegant than git (at least for me).

    Anyway I don’t want to use cvs or svn anymore since I’ve tried DCVS.

    Regards from Canary Islands

  • Mercurial works with one click on windows, linux and mac (i’ve used it on all these platforms), thanks to be written in python. When I chose it, git didn’t work easily on windows (you know, you had to install cygwin, or msys or this kind of things). I didn’t test the alternatives as it did the job for me. ( And you can use bitbucket.org as the central repository).

    (sorry for the bad english , iba a escribirlo en castellano, pero mira…)

  • WOW!!! Honte!! “Long time, no see” … :D

    But I don’t use Windows nowadays (yesss!).

    No worries about the english, it’s perfect! Pásate más por aquí, oyesh!

  • How about Bazaar? Anybody tried it?

    When I tried Git there was even a Win version, as Honte said. I preferred to stick to SVN as it was a step further than CVS. Now I’m willing to try a new SCM, so I’m pondering Git and Bazaar. Git seems to have evolved a lot.

  • I guess it depends on what you’re looking for. What I like about git is there’s a LOT of documentation about it right now, including guides comparing it with SVN and other version control systems, so you can see what can be done without having even to install it.

    But at the end you’ll have to pick one, play with it, and see how it goes… if it works for you or is too cumbersome etc.

  • Long long time. I’ll put your blog on my reader.
    I had one of these “what happened to those demoscene people” moment, and I read some of your posts.

  • No rss feed !?

  • It is there right to the page url — in the address bar: http://soledadpenades.com/feed/

    It’s RSS2.0

    Or were you looking for the feed link in the right column? I think I had it there at some point and for some reason I removed it… I’ll add it again, maybe there’s more people looking for it :)

    Thanks for the (indirect) suggestion!