Question

I'm in the process of converting a large repository from SVN to Git. I've used SVN2Git to handle the conversion. However, it takes a very long time. So, I've been using the svn2git --rebase command to bring in changes while we test, prepare our CI and build infrastructure, etc.

However, I'm unsure how I'm supposed to be handling changes to branches, or branches that get added. For example, someone created a branch today, and I need to bring it in. I ran my svn2git --rebase (against [master]), and it updates master as expected but the new branch didn't get converted over.

This makes me question whether or not it's updating the existing branches. So, what does svn2git do during --rebase, exactly, but more importantly, how can I make sure my branches are getting updated and any new ones are also being converted?

I'll even settle on how to manually convert or update git branches from svn, as there aren't many, but they are important.

Was it helpful?

Solution

In my case, I just ended up calling svn2git with the same parameters as I had originally used, except I used -revision to skip ahead to the commit of the branch I'm interested in.

I'm not sure if that's the correct way, but it worked for me.

OTHER TIPS

I've found that with svn2git, even while using --rebase, the branches aren't always kept up to date. So if you run:

svn2git --rebase

...and you still don't have your local branches up-to-date, then you may need to update your local refs manually after svn2git has run. (Don't do this on your current branch, as it will fail. Switch off of master first.)

git branch -f master remotes/svn/trunk

This forces your local Git master branch to be at the same commit as the remote SVN trunk branch.

If you have a lot of branches to do this for, then the following loop should be able to correct this for you (make sure your current branch isn't in this list -- might as well switch to master):

for i in `git branch -a \
| grep remotes/svn | grep -v trunk \
| sed -e 's/^  remotes.svn.//'`; do
    git branch -f $i remotes/svn/$i
done

Just be aware that doing so will overwrite any commits you've made to Git on that branch. I'd suggest this only in the case where you have not yet started using the Git repository.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top