1

Hi I am stuck with the problem where I have to delete some commits that appered in my PR from previous branch I was working on. Unfortunately I didn't see them at first so I already made a few commits and push all of this into remote branch. Commits that are not needed are in black lines

enter image description here

Commits around black lines are already merged into master too. All I had to do is to delete them from my current branch and push. I have tried solutions described there, but git revert doesn't recognize that I solve some conflicts problems and not allow me to revert it.

Does anyone has an idea how to remove these commits?

mike
  • 1,233
  • 1
  • 15
  • 36
Eddy
  • 593
  • 8
  • 22

1 Answers1

2

You should use a git rebase --interactive and drop the commits that are not needed anymore.

You might have to do a git push --force to push your branch again if you've already pushed it prior.

Gimly
  • 5,975
  • 3
  • 40
  • 75
  • Not necessarily, in the question he states that the commits that he wants to not merge again were already merged. This might happen if you work with multiple branch and you've squashed merged a branch but have another one that had commit in common. In that case, you would drop "duplicated" commit and therefore not lose code. But if the commit has not been merged, yes it can mean drop code. – Gimly Apr 12 '21 at 08:26