Undo a commit in the middle of a Git history
2 answers
You must use git revert <SHA>
for this. This will ensure that the changes you make are tracked and if some other developer now pulls into the branch, they won't run into problems / conflicts because the stories are out of sync.
On the other hand, the usage git cherry-pick
is mostly used to select a commit and apply it on another branch and therefore won't work here.
You can also use interactive redirects to undo / redirect your changes, but this can lead to conflicts on other development machines.
+2
source to share