Skip to content

Git, SVN and Development

It seems I have read quite a few posts in the last half a year or so on the virtues on decentralised version control and how good git it. Before my laptop died I had installed git and was using it for development. Unfortunately that was pretty short lived due to the failure of my laptop. Now all of my development is taking place on Apple Mac machines using Leopard (I used Tiger for a while too).

Recently I built git from source on the laptop I am using and checked out the full Avogadro subversion repository using the following commands.

git svn init -t tags -b branches -T trunk https://avogadro.svn.sourceforge.net/svnroot/avogadro
git svn fetch

Then I went and grabbed a coffee while it imported over 800 commits which is pretty small compared to many of the other repositories I have heard about being imported. It didn't take too long, but I would happily make my git repository available should anyone want a copy.

I have found git to be very fast which is absolutely great. There are some things which I have found a little confusing while getting to grips with git and its interaction with the subversion repository.

For my day to day work I need very few commands. git svn rebase synchronises with the subversion repository. I really like this way of updating too as it displays the diffs for the commits and the log messages. git commit -a commits all local changes to the local repository. git status shows the current status of the repository, git show shows local changes already committed and git svn dcommit pushes my local changes to the subversion repository.

It is this last feature I think I like the most. I can queue up multiple change sets which might actually break Avogadro, giving nice bite size commits as I make progress, but only committing them once I am done and everything is working (at least reasonably well). Then there is the potential for doing this when off line which is also great.

One of the most confusing things I found was how to nuke local changes if I didn't want to keep them. Deleting the file and updating doesn't work as it does with subversion. Also revert didn't do what I was after. I finally found git checkout which was not what I was expecting. Issuing the command with no arguments resets the repository to the last committed state. Adding filenames as arguments reverts just those files.

Another one I haven't found the answer to is files reappearing that we long since deleted. The avogadro.pro file is the main one left but a set of directories also reappeared. They are not there when checking out using just subversion. If anyone has the answer I would love to know. If I git rm the file the commit to subversion does nothing and it loops round.

Other than that I am really happy with git. It can be a little too easy to use the wrong commands and wipe out changes so I am moving quite gingerly at times but I think it is well worth the trade off. A few guides such as this one, this one and of course this have helped me along the way.

UPDATE: Just to note that I was using the git 1.5.3 release compiled from source.

Trackbacks

No Trackbacks

Comments

Display comments as Linear | Threaded

Lee on :

LeeHmm. The only time I've had trouble with reappearing files was when I guessed how branch rebasing worked in git instead of actually reading the docs. As a result, the branch/version I thought was "head" wasn't. The svn plugin sounds too sophisticated to break that, unless you're using a bleeding edge version. You might find a branch/revision visualiser helpful for debugging.

Marcus D. Hanwell on :

Marcus D. HanwellThere was no guessing of how branches worked - I just followed the instructions and issues the commands at the top of this post. I am just using the 1.5.3 release downloaded from the web site and compiled locally. No bleeding edge stuff, I just wanted to give git a try and see how it worked with subversion repositories.

Peter Baumann on :

Peter Baumanngit will only create directories if you have files in them tracked with git. That's also the reason why you can't have an empty directory. So have a look (eg. with gitk --all) if you are working on the right branch and if there are still
files tracked in those 'deleted' directories. git also won't delete directories with files it knows nothing about, e.g if
you have .o files in dir/, it won't delete it.

Marcus D. Hanwell on :

Marcus D. HanwellYeah well git definitely showed three directories which were filled with files. None of the files or directories exist anymore in the subversion repository. All I did was issue the commands. If you are interested I will put up a copy of the repository. It still has the avogadro.pro file that was deleted in the Avogadro repository some time ago. Not sure how to fix that to be honest.

I am working on trunk, can commit back to the subversion repository etc and that works great. Just this file that won't go away... More a minor annoyance than anything else. May be when I get more time I should report a bug but wanted to ensure it wasn't my own mistake first.

Peter Baumann on :

Peter BaumannI am definitly interested in figuring this out, because I use git-svn almost daily and want it to be bug free. And from lurking on the git mailing list I can't remember anyone else seeing it.

Feel free to reach me via email.

Marcus D. Hanwell on :

Marcus D. HanwellI just wanted to note that we did get to the bottom of the issue and it was fixed some months ago. Thanks to Peter and the author of git svn :-)

Nicola Fontana on :

Nicola Fontana"...how to nuke local changes..."

Maybe I'm a bit late, but does git-reset --hard not work for you?

Marcus D. Hanwell on :

Marcus D. HanwellWhat I was actually looking for was git checkout. I wanted to revert local, uncommitted (locally) changes when I decided they were useless. Still using git and it is my primary version control system, mainly working with SVN as the centralised version control.

Thanks for the suggestion - I certainly use git reset too after I committed something locally and realised it was not a good commit.

Add Comment

Enclosing asterisks marks text as bold (*word*), underscore are made via _word_.
Standard emoticons like :-) and ;-) are converted to images.
E-Mail addresses will not be displayed and will only be used for E-Mail notifications.

To prevent automated Bots from commentspamming, please enter the string you see in the image below in the appropriate input box. Your comment will only be submitted if the strings match. Please ensure that your browser supports and accepts cookies, or your comment cannot be verified correctly.
CAPTCHA 1CAPTCHA 2CAPTCHA 3CAPTCHA 4CAPTCHA 5


You can use [geshi lang=lang_name [,ln={y|n}]][/geshi] tags to embed source code snippets.