Reputation: 6713
I am planning a svn to git migration of a bunch of repositories. Two of them are in a particular state.
A project has been developped in a svn repo. Due to various constraints, the project has been forked at some point. The fork has been made by duplicating the svn repo. After that point, the two projects evolved separately. No branches or tags exist in either repo besides the trunk.
A significant functionality has been developed for the original project and needs to be ported to the fork. In the current situation this could be done by creating a patch from the various revisions and applying it on the forked project. This has the advantage of short term simplicity in the current situation but has a number of unwieldy consequences on the long term.
We could have two distinct git repos and do cross-fork porting via pull requests, but this could lack usability (we're not using github). Besides there may come a time where we might want to reintegrate the fork into the parent project thanks to modular design refactoring. Another approach would be to merge the two svn repositories into a single git repository as distinct branches, and manage subsequent merges from there (with all the advantages that it gives).
Ideally I'd like to recreate the true history of the project, that is have a git repo with:
An interesting fact that might help, the following command produces identical SHA1s for the common commits:
git svn clone -s -A svn.authors --no-metadata http://subversion.foo.local/repo/path git_migration
I don't care about --no-metadata
because it's a one-way migration.
How could I achieve such a result, if even possible?
Upvotes: 4
Views: 314
Reputation: 10853
Since you have a way to clone the SVN repos with identical hashes for common 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
Now you must have common history in master
and 2 branches for the different SVN repos.
Upvotes: 2
Reputation: 393674
Joining history to a single root in general can usually be done using git Graft Points
Il refer you to
https://git.wiki.kernel.org/index.php/GraftPoint
In simplistic terms, you just tell git which revisions share a certain parent revision (a magic 'merge' result if you will). Once you're happy you can cast 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
Upvotes: 2