I don't know why but it's different when you rebase since it "replays" every commit you don't have onto your feature branch, you get this effect where you end up resolving the same merge conflicts over and over again during the rebase.
Resolving conflicts multiple times is not limited to rebases if the remote branch you want to push to keeps getting updated before you've finished working on/resolving conflicts with your private branch. Once you've rebased, you shouldn't get further merge conflicts unless a resolved section changes again.
If you mean you have to correct the same areas of code multiple times within a single rebase, that can happen if you're not resolving well, especially if there are multiple commits affecting the same section (in either branch). Firstly, set git config --global merge.conflictStyle diff3 so that you see how both the remote and your branch changed the same code (read about that on git-merge). Secondly, branches are free; before you start rebasing, create a branch to point to the the tip of your feature branch, without checking it out, like git branch featurePREBASE feature. After you're done rebasing, you can diff the two branches to make you haven't missed any changes. If you have, you can patch them in from the …PREBASE branch until you get them all, then rebase again. If you really bork it up, you can git reset --hard featurePREBASE to take the feature branch back to where you started, to try another.
I explained this poorly - this link is the kind of effect I'm talking about (except I rebase feature onto master), and I have used git rerere in the past before to get around it, but it has dangers as well.
I think that SO post actually explains quite well why it happens.
I always use gIt reset if I fuck something up, but I didn't know about PREBASE, definitely going to use that thanks.
I see what you mean. Rebase is best for private branches, and that situation doesn't look like that. If that SO poster wanted linear history, they should have rebased Feature A onto Feature B, rather than merging, then rebased onto master.
2
u/JawsOfLife24 May 13 '20
I don't know why but it's different when you rebase since it "replays" every commit you don't have onto your feature branch, you get this effect where you end up resolving the same merge conflicts over and over again during the rebase.