I have a Git repository hosted in GitLab and I want to migrate it to Subversion.
I could export the code and push them to svn repository, but how could I migrate the all commit logs in git to svn repository?
I have a Git repository hosted in GitLab and I want to migrate it to Subversion.
I could export the code and push them to svn repository, but how could I migrate the all commit logs in git to svn repository?
This method just suitable for only master branch's git repository.
1, git clone
from exist git repository, and cd
git workspace.
2, git svn init -s svn_url_such_as_http://svn.com/your.svn.repository
3, check the git configure file .git/config had only include these content in [svn-remote "svn"]
block:
[svn-remote "svn"]
url = https://your.svn.repo
fetch = :refs/remotes/git-svn
4, git svn fetch
and you will get the svn's last commit id like:
r1024 = 37c9910f794cb9cff7ca0d5d2eb26e1f0dabbc4d
5, get current git's first commit id by git log | tail
:
commit c6694fa5e371ed579cfc1a4a708af561883ab5fd
Author: victor <...>
Date: Wed Feb 8 20:15:00 2017 +0800
Initial commit
6, git svn dcommit
get error: Unable to determine upstream SVN information from HEAD history
:
This fails since the git svn command can't figure out which commits to push: there's no link between our original Git repository and the Subversion heads. To fix this, we can use a Git graft to link them. We'll tell Git the commit which created the SVN folder in which we want to store the project is the parent commit of the first commit in our Git repository.
let git's first commit after svn's last commit by .git/info/grafts prevent issue the above error:
echo "c6694fa5e371ed579cfc1a4a708af561883ab5fd 37c9910f794cb9cff7ca0d5d2eb26e1f0dabbc4d" >> .git/info/grafts
7, git svn dcommit
success and svn up
in your svn repository working path.
One more thing: the svn log commit time and author are consist with git svn dcommit
. could it be resolved? But it's not a problem for me.
Thanks for Alex Rouillard
and andrej
's answer.