1

If I have a branch with a number of commits, push it to the server, and create a PR in Bitbucket for it, chances are that these commits get changed remotely. For example, someone might click the "Rebase" button in the PR.

When I work on this branch again, I want to incorporate all remote changes into my local branch (which might also be ahead of the remote version by some new commits). Therefore I pull, creating a merge commit.

If I push my branch again, all my commits appear twice. I absolutely don't want that. But I don't know how to prevent that.

Is there a workflow which is as simple as merging (i.e. I don't have to fix the same conflicts for each commit, as sometimes happens during rebasing), but still creates a history without duplicate commits?

Felix Dombek
  • 13,664
  • 17
  • 79
  • 131

1 Answers1

0

Try instead to rebase your local PR branch on top of the updated PR one.

git checkout PR-branch
git fetch
git rebase origin/PR-branch

Any common commit of your branch should not be repeated (replayed) on top of the remote tracking branch origin/PR-branch if they are identical.
Then you can git push --force to update the PR

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250