SVN to git migration preserving branches

Marek Hobler November 27, 2017

I try to migrate out svn repo to the bitbucket.  My command history:

# git svn clone --authors-file=./authors.txt --trunk DBApp2/trunk --tags DBApp2/tags https://svn.server/reponame/ ad

# java -Dfile.encoding=utf-8 -jar ~/svn-migration-scripts.jar clean-git
# git branch -a

master
remotes/origin/BIN
remotes/origin/BIN@400
remotes/origin/ExListCtrl
remotes/origin/ExListCtrl@400


[....]

# git remote add origin http://mhobler@bitbucket.server:7990/scm/dat/ad.git

# git push -u origin --all
Password for 'http://mhobler@bitbucket.server:7990':
Counting objects: 91286, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (17631/17631), done.
Writing objects: 100% (91286/91286), 484.04 MiB | 34.09 MiB/s, done.
Total 91286 (delta 74607), reused 89339 (delta 72953)
remote: Resolving deltas: 100% (74607/74607), done.
To http://bitbucket.serverl:7990/scm/dat/ad.git
* [new branch] master -> master
Branch master set up to track remote branch master from origin.


 As you can see, there is only one branch pushed to server. The bitbucket web interface also shows only one branch (master). 

 

How can I push other branches to server?

1 answer

1 accepted

1 vote
Answer accepted
Steve Thornhill
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
November 28, 2017

Check the .git/config file and see what has been added in there.

If you find the branches are still listed and svn remotes you will need to rename them to 'branches' to get the push to work correctly.

Marek Hobler December 7, 2017

Thank you. Can you please be more specific?  What should I rename? How?

 

my .git/config looks like this:

[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[svn-remote "svn"]
url = https://svn.server/reponame
fetch = ad/trunk:refs/remotes/origin/trunk
branches = ad/qb*:refs/remotes/origin/*
branches = ad/QB*:refs/remotes/origin/*
branches = ad/devel*:refs/remotes/origin/*
branches = ad/Polaris/*:refs/remotes/origin/*
tags = ad/tags/*:refs/remotes/origin/tags/*
branches = ad/qb*:refs/remotes/origin/*
branches = ad/QB*:refs/remotes/origin/*
branches = ad/devel*:refs/remotes/origin/*
branches = ad/Polaris/*:refs/remotes/origin/*
tags = ad/tags/*:refs/remotes/origin/tags/*
[svn]
authorsfile = /home/marek/gitmigration/authors.txt
[remote "origin"]
url = http://mhobler@bitbucket.server:7990/scm/reponame/ad.git
fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
remote = origin
merge = refs/heads/master
[gitg]
mainline = refs/heads/master
Steve Thornhill
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
December 7, 2017

I run the following sets of commands on a new copy to ensure they match up to git expectations.

 

cd ${repo_name}
sed '/svn-remote/a branches = ' .git/config > .git/newconfig
sed '/svn-remote/a tags = ' .git/newconfig > .git/config
#java -Dfile.encoding=utf-8 -jar /usr/local/cpa_bb/repos/svn-migration-scripts.jar clean-git --force
for branch in `git branch -r | sed 's/ origin\///'`; do echo $branch; git branch $branch remotes/origin/$branch; done
cd ..
Marek Hobler December 7, 2017

Thank you so much, it fixed the issue here. 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events