Suppose I have a branch A
that I've been working on that corresponds to a merge request. A
runs a few commits ahead of origin/A
and someone else mistakenly merges this branch in. Now all the commits in origin/A
have been flattened, and now I have to replay all these commits between origin/A
and A
onto a new branch created from master
and submit a new MR for this. What's the right way to go about this? Manually I'd just cherry pick them over, but I have to imagine there's a more natural way to go about this.
Detect what was the last commit that was squash merged from your branch and let's call that commit X
. Once you have that, you can run:
git rebase X my-branch --onto the-upstream-branch
That way you will only rebase commits that are after X
.