0

Instead of deleting a faulty commit from master branch, is there a good way to add a new commit on top that somehow reverts the same changes as the faulty commit introduced?

In other words, we merged a commit that introduced a regression so we want to "undo that commit" but we'd rather not delete the commit somehow since then existing feature branches would have to be forced merged/pushed to master.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
  • 1
    Does this answer your question? [Undo a particular commit in Git that's been pushed to remote repos](https://stackoverflow.com/questions/2318777/undo-a-particular-commit-in-git-thats-been-pushed-to-remote-repos) – mkrieger1 Mar 29 '20 at 19:39

1 Answers1

0

Use git-revert.

git revert <commit>

It creates a new commit that negates the changes the specified commit introduced.

krisz
  • 2,686
  • 2
  • 11
  • 18