0

I wanted to create a PR on a new target branch but Im getting an conflict because the old feature branch is created using old target branch and creating a PR to new branch will create an error.

so I am doing these steps:

  1. create new branch from new target branch
  2. squash all commit into one commit
  3. cherry pick the squashed commit into feature branch
  4. force push into remote branch

My question is how can I squash all commits into one commit ?

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
guradio
  • 15,524
  • 4
  • 36
  • 57
  • 1
    What **platform**? Pull requests aren't a native Git feature. Every Git host that supports pull requests has their own implementation. – Daniel Mann Nov 22 '22 at 06:23
  • @DanielMann im using bit bucket..i thought they are all the same – guradio Nov 22 '22 at 06:26
  • @DanielMann please disregard the PR.. my question is if i have two commits how can i squash them into one commit so that I can use cherry-pick to that commit ? – guradio Nov 22 '22 at 06:28
  • If the commits were separate for a good reason, copy them to new-and-improved but still separate commits using `git rebase`. If the commits were separate for a bad reason, why were they separate in the first place? – torek Nov 22 '22 at 15:04
  • @torek they were separate because they are fix after Peer Review – guradio Nov 23 '22 at 02:13

1 Answers1

2

my question is if i have two commits how can i squash them into one commit so that I can use cherry-pick to that commit ?

As mentioned in "How do I squash my last N commits together?", with a combination of reset --soft+commit:

git switch oldTargetBranch
git reset ‒soft commitBeforeYourTwocommits
git commit -am "squash old branch"

git switch newTargetBranch
git cherry-pick oldTargetBranch
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250