Reputation: 5329
I have migrated my project's Subversion repository to Git, as per How to migrate SVN with history to a new Git repository. It worked very well except there is one disconnected branch due to some incorrect use of Subversion in our history. I'm not sure what the terminology is to describe the state of this branch. Here's what it looks like:
trunk: ...-A1---> <---A3----A4-...
beta: B1--B2--B3--B4----B5
From what I can tell, this is what happened. At revision B1 a new "beta" branch was created by using cp instead of svn cp. At revisions B4 and A3 the entire repository was moved from /svnroot/project/orig to /svnroot/project (I don't think this is related to the problem but I mention it just in case). At A4 the "beta" branch was merged back into trunk using mv and rm commands instead of svn merge.
How can I fix the Git repository history so that B1 correctly branches from A1 and B5 merges back into A4? Note there are actually 75 revisions in the "beta" branch.
Upvotes: 1
Views: 858
Reputation: 28951
git checkout beta
- take the branch.
git rebase A1
- move beta's commits on top of A1.
git checkout A4
- switch to the A4
git checkout -b new_merge_point
- create a temp branch for the merging
git merge beta
- the merge. Could be conflicts?!.
git checkout trunk
- back to trunk
git rebase new_merge_point
reapply commits after A4 to the new merge point.
Upvotes: 0
Reputation: 244817
You can use grafts to create fake ancestry information. Create file .git/info/grafts
and put something like this into it:
B1 A1
A4 A3 B5
But instead of the names of commits from your schema, put their full SHA1s. After this, make sure that the history looks the way you want it. If it does, you can make the grafts permanent by git filter-branch --all
.
Of course, doing this rewrites history and it's a bad idea if anyone else already has a clone of your git repo.
Upvotes: 2