Figuring this git thing out

Vincent Danen

October 29, 2011

I'm a little old-school in that I like subversion. I've used subversion for years, and have had it as a big part of my workflow for a really really long time. Unfortunately, there's this git thing popping up all over the place and I'm starting to feel dated. (It's bad enough that my daughter turned 10 this month, which makes me feel old, so I have to find other ways of not feeling out-dated!).

The problem is that all of my version control repos are in subversion, and I hate losing history. On some, I went through a painful CVS->SVN migration when I first started using subversion, and I was pleasantly surprised that git makes it quite a bit easier. I found this blog posting that helped me (for the most part... if you don't use tags and branches, etc. you want to pay attention when doing some of the steps... took me a bit to figure that out). Most notably, in steps four and five when changing the "trunk" to "master"; it assumes you have the standard trunk/, tags/, branches/ layout (which I do in some repos, and not in others). If you use that convention, it works fine. If not, you can run into problems like I did.

The posting indicates to use:

git svn clone [SVN repo URL] --no-metadata -A authors-transform.txt \
   --stdlayout ~/temp
...
git init --bare ~/new-bare.git
cd ~/new-bare.git
git symbolic-ref HEAD refs/heads/trunk
cd ~/temp
git remote add bare ~/new-bare.git
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare
cd ~/new-bare.git
git branch -m trunk master

But this didn't work for me, as --stdlayout isn't so standard in my case (no tags/trunk/branches, so the top-level is the "trunk"). Instead I had to do:

git svn clone [svn repo] -A authors-transform.txt ~/tmp/git
cd ~/tmp/git
git init --bare ~/git/scripts.git
git remote add bare ~/git/scripts.git
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare
cd ~/git/scripts.git
git branch -m git-svn master

In this case, the only branch is the "git-svn" branch, so we want to turn "git-svn" into "master" (rather than trying to hunt down some non-existant branch called "trunk"). There might have been a better way to do this, but I'm a n00b so forgive me. All the explanation for the above is in that blog post I mentioned before (I'm mostly noting this as undoubtably I'll bump my head against this again).

Some other useful links I found were this git guide and a piece on setting up gitweb on Fedora (works on RHEL also). Gitweb was essential, as I'm used to using viewvc with my subversion repos.

So will I use git for all my repos? Probably not. There are some old ones that don't need to be converted because it's all legacy code, and there are some others that I've built up with too much automation. I would like to try to extract some pieces of existing subversion repos into git, however. The AIDE+gpg scripts are one; they're in the Annvix tools repo, and I'd like to try to break it out into it's own git repo with history... not sure if this is possible but I'll poke around and see what I can come up with. There are a few other Annvix tools that I'd do the same with (the rsec tool for one). Since Annvix isn't in development anymore, I'd like to "untie" those tools from it and offer them as stand-alone things (probably on github or something).

So that's my Saturday adventures for this weekend. =)

Leave a Comment

Comments use MarkDown. Need help? MarkDown Cheatsheet