1

I created a feature branch from main branch then opened a pr from feature branch to main branch then after a while squash merged main branch into my feature branch to keep it up to date Now i have changes from main branch as additions in the pr and they also exist in my feature branch How can i display in the pr only the changes from feature branch that aren't on main branch?

I tried closing the pr then reopening it but still shows me changes that i didn't make

  • 2
    You probably want to revert that squash merge. Generally, I recommend updating a feature branch by rebasing it on the tip of the base branch. – Benjamin W. Jan 23 '23 at 19:51

2 Answers2

3

When prepping for merging a personal feature branch into main, if you wish to update your feature branch with the latest changes from main, you generally should do one of the following:

  1. Rebase your branch onto the latest main and then force push2 your feature branch to update the PR.
  2. If there is a reason that you shouldn't do #1, (for example if your feature branch is not a true feature branch and is instead a shared branch), then you should merge main into your feature branch using a regular merge.

Squash merge should not be used for updating a feature branch with the target branch of a PR.1


1There are some exceptions to this rule, such as when the target branch is a shared branch that gets periodically reset, such as the next branch in gitworkflows. In that case squash merge is helpful to make a future interactive rebase easier, when promoting the feature branch to another branch such as main in a future PR.

2 Use your favorite flavor of force pushing. I tend to prefer --force-with-lease, though nowadays some prefer using: --force-with-lease --force-if-includes. See this question for more details.

TTT
  • 22,611
  • 8
  • 63
  • 69
0

I reverted the merge of main into my feature branch and the problem was solved I'll try to rebase when updating my branch.

SwissCodeMen
  • 4,222
  • 8
  • 24
  • 34