1

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?

Victor Lee
  • 2,467
  • 3
  • 19
  • 37
  • This might help: https://stackoverflow.com/questions/498110/converting-a-repository-from-git-to-subversion – joanis Feb 15 '22 at 13:45
  • This Google search yields a lot of hits, I'm sure your answer is already out there in one of these: https://www.google.com/search?q=convert+git+repo+to+svn – joanis Feb 15 '22 at 13:46
  • Could it push the commits logs to svn? I will try, thanks. I haven't idea to use the convert keyword to search before. – Victor Lee Feb 15 '22 at 13:56
  • https://stackoverflow.com/questions/63368720/migrate-from-git-to-svn-with-full-history but... SVN if you have DVCS?! – Lazy Badger Feb 15 '22 at 14:20

1 Answers1

0

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.

Victor Lee
  • 2,467
  • 3
  • 19
  • 37