Home > Net >  Git conflict on PR when target branch is changed
Git conflict on PR when target branch is changed

Time:11-22

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 ?

CodePudding user response:

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
  •  Tags:  
  • git
  • Related