6

I have created 2 commits to remote dev branch. That I squashed and merge into remote master branch.

Now when I want to continue with working on dev branch - I don't know how can I correctly "repair" my branches - because after creating new pull request from dev to master I get list of all commits which were squashed in previous pull request.

I have something like this:

O ---- A ---- B ---- XY <--(master)
 \
  X ---- Y ---- Z <--(development)

How can I create correct pull request with commit Z from dev to master?

Jenan
  • 3,408
  • 13
  • 62
  • 105

2 Answers2

5

Before adding new commits to your dev branch, you should first reset it to origin/master, since you squashed/merge dev to it.

In order to not break anything, create a new branch from origin/master:

cd /local/repo
git fetch
git checkout -b newBranch origin/master

Then report back your new commits on that new branch:

git cherry-pick Y..Z

Finally, reset your dev branch to said new branch:

git checkout dev
git reset --hard newBranch

And force push: git push --force.

The end result would be a new PR with only the new commits

Nicolás Alarcón Rapela
  • 2,714
  • 1
  • 18
  • 29
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

If you're unable to correctly determine the Y commit, in case we're talking about a much more complex scenario, reverting the XY commit from master also works:

git checkout master
git revert XY
git push

Then your pull request from dev to master will have no conflicts anymore.

ericbn
  • 10,163
  • 3
  • 47
  • 55