i finally took the plunge and started using git to manage my code. since we use subversion at work, i’m using git-svn to collaborate with them.

initially, i just followed the simple starting instructions, which don’t use the –prefix option to git svn init.

it wasn’t long before i saw someone’s suggestion to add a svn prefix to the remote branch names.. as a way of segregating the namespace, and to easily allow me to have local branches that have the same name.

i searched around, but there weren’t any explicit instructions on how to add the prefix post-init. well, you can. here’s how.

in your .git/config, there will be a block for the SVN configuration:

[svn-remote "svn"]
	url = http://example.com/your/repo/root
	fetch = trunk:refs/remotes/svn/trunk
	branches = branches/*:refs/remotes/svn/*
	tags = tags/*:refs/remotes/svn/tags/*

what you will want to do is edit this file and add the /svn entries that i have in bold.

then, re-run git svn fetch. this will populate the new branches. thanks to the metadata git-svn keeps, its aware that there are already local commits that correspond to specific SVN revisions.

finally, you can delete all of the old branches using something like git branch -d -r | grep -v svn | xargs -n 1 git branch -d -r

then sit back and bask in your new prefixed life :)

Tags: , ,

2 Responses to “adding a prefix to git svn repositories”

  1. big_gie Says:

    Shouldn’t the “delete all old branches” be:
    git branch -r | grep -v svn | xargs -n 1 git branch -d -r
    and not:
    git branch -d -r | grep -v svn | xargs -n 1 git branch -d -r
    ?

  2. osi Says:

    @big_gie: yes, you are correct!

Leave a Reply