I've decided to retrospectively commit a history, that was never in Git, from an other old version control system. So I've created an orphan branch "newroot", and imported commits from the other version control system to it. Following question Insert a commit before the root commit in Git?
The "newroot" branch ended up with files exactly matching the root commit of the "master" branch.
Now I want to rebase the "master" branch onto the "newroot" orphan branch, like:
git rebase --onto newroot --root master
The problem is that I get prompted to resolve all merge conflicts. There are hundreds of merges over a span of many years. I'm just not capable of resolving them manually. And there's really no need, as these merges were already resolved in the past. As the rebase actually does not change contents (as I'm rebasing on an identical tree), I want Git to "replay the merge" exactly.
Is there a way to specify that the rebase should use the same resolution as was used previously?
I understood that the "rerere" may help here. But I would had to have it enabled already, when originally merging, right? Or can I retrospectively recreate the "rerere" cache?
I can imagine an alternative solution to my task. To somehow ask Git to concatenate the "newroot" and "master" branches, without actually rebasing. But I'm not sure if that's possible.
Because of at least two reasons: Rebasing changes the commit IDs (i.e. the SHA-1 hashes of their metadata). This means that once you push the rebased commits to the shared branch, they will appear as completely new commits to anyone that fetches them on their local repo, even if they still contain the same changes.
Changing older or multiple commits. To modify older or multiple commits, you can use git rebase to combine a sequence of commits into a new base commit. In standard mode, git rebase allows you to literally rewrite history — automatically applying commits in your current working branch to the passed branch head.
To somehow ask Git to concatenate the "newroot" and "master" branches, without actually rebasing. But I'm not sure if that's possible.
That is called a graft point, followed by a filter-branch
in order to rewrite master history.
See this post as an example or this question.
On the rebase side, you can try and use a merge strategy like theirs, to resolve any conflict using the master branch content (since master is being rebased)
git rebase --merge -s recursive -X theirs --onto newroot --root master
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With