Transferring two svn repositories with a common history to git

I am planning svn for git repository group migration. Two of them are in a certain condition.

A project was developed in svn repo. Due to various restrictions, the project was forked at some point. The fork was made by duplicating the svn repository. After that, two projects developed separately. There are no branches or tags in the repo except the trunk.

Significant functionality was developed for the original project and should be transferred to the plug. In the current situation, this can be done by creating a patch from various versions and applying it to a forked project. This has the advantage of short-term simplicity in the current situation, but has a number of cumbersome consequences in the long run.

We could have two different git repositories and cross-migrate through pull requests, but that might be a loss of convenience (we don't use github). In addition, it may take time when we want to reintegrate the plug into the parent project due to the modular reorganization of the design. Another approach would be to merge the two svn repositories into one git repository as different branches and manage subsequent merges from there (with all the benefits it gives).

Ideally, I would like to recreate the true history of the project, i.e. have a git repository with:

  • one branch consisting of commits to the fork
  • two different branches, consisting of a parent and a fork, commit to HEADs

An interesting fact that may help, the following command creates identical SHA1 for shared commits:

git svn clone -s -A svn.authors --no-metadata http://subversion.foo.local/repo/path git_migration 

I don't care --no-metadata , because it's one-way migration.

How can I achieve such a result, if possible?

+4
source share
2 answers

Since you have a way to clone SVN repositories with the same hashes for shared commits, this should work.

 git svn clone -s -A svn.authors --no-metadata http://subversion.foo.local/repo1/path git_migration git svn clone -s -A svn.authors --no-metadata http://subversion.foo.local/repo2/path git_migration-2 cd git_migration git branch repo1 # Branch for first repo git reset --hard <highest_common_hash> # To have only common history on master git checkout -b repo2 # Branch for second repo git pull ../git_migration-2 master 

You should now have a common history in master and 2 branches for different SVN repos.

+2
source

Combining history into a single root can generally be done using git Graphics.

Il refers to

https://git.wiki.kernel.org/index.php/GraftPoint

In a simplified expression, you just tell git which versions share a specific parent revision (the result of a "merge" of magic if you do). When you are happy, you can throw it in stone using git filter-branch

Sample from man git-filter-branch

 echo "$commit-id $graft-id" >> .git/info/grafts git filter-branch $graft-id..HEAD 
+2
source

All Articles