Home > Net >  How to get a rebase from a git branch that has done numerous git merge and pulls
How to get a rebase from a git branch that has done numerous git merge and pulls

Time:10-26

I want to be able to get a clean rebase on a branch someone else has worked on using a merge resolve conflict strategy.

  1. What's the easiest way to accomplish that?

  2. Can I reuse their previous conflict resolutions along the way?

CodePudding user response:

You might still need to resolve conflicts, but I would look into git rerere that I mentioned in "Are there any downsides to enabling git rerere?".

You can activate rerere and train it, in order for git to record past conflict resolution.

CodePudding user response:

The easiest way to accomplish this (assuming main is the branch to rebase on top of) would be

git branch someone_elses_branch.rebased someone_elses_branch
git rebase main someone_elses_branch.rebased

This will have git attempting to apply the commits from someone_elses_branch.rebased on top of main and if there is a significant amount of changes between the common merge base and the top of main you might end up with conflicts due to the aggregate of them being applied at once, while if you had rebased the branch just one commit at a time you could have avoided some of them.

Therefore you could try out using git-imerge instead which basically does that, rebasing incrementally along all commits on a branch.

  • Related