Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wrong(?) branch prefixes migrating SVN to Git

Tags:

git

svn

I basically followed this howto to migrate an old, very big SVN repository to git. This does not work as expected. Here is an example excerpt from my checkout living in ~/git/old_svn_repo (done with git svn but without --no-metadata):

remotes/origin/trunk
remotes/origin/branchX
remotes/origin/branchY # and many more

Next step is step 4, which seemed to work flawlessly. I pushed to the bare repository (note I used ~/git/new-bare.git instead of ~/new-bare.git):

git init --bare ~/git/new-bare.git
cd ~/git/new-bare.git
git symbolic-ref HEAD refs/heads/trunk
cd ~/git/old_svn_repo
git remote add bare ~/git/new-bare.git
git config remote.bare.push 'refs/remotes/*:refs/heads/*'
git push bare

This got me a lot of output like

* [new branch]      origin/trunk -> origin/trunk
* [new branch]      origin/foo-> origin/foo
* [new branch]      origin/bar-> origin/bar

Next is step 5 where you are supposed to rename trunk to master:

cd ~/git/new-bare.git
git branch -m trunk master

Here the problem starts:

I enter:

git branch -m trunk master

I get:

error: refname refs/heads/trunk not found
fatal: Branch rename failed

Doing git branch -a reveals that all branches are prefixed with origin/.

What did I do incorrectly here and how do I get that right?

like image 229
rabejens Avatar asked Nov 17 '15 15:11

rabejens


1 Answers

After several failed attempts at this (I had the same issue, an extra directory named origin in the refs/remotes path.) I made it work with this minor tweak.

git config remote.bare.push 'refs/remotes/origin/*:refs/heads/*'

Additionally in the create .gitignore step I used:

git svn show-ignore -i origin/trunk > .gitignore

Which worked as intended.

I'm not sure where the extra origin dir comes from in this, but these mods worked for me.

like image 175
Jordon Davidson Avatar answered Oct 01 '22 22:10

Jordon Davidson