Is there a way to undo commits on a protected branch?
I mean, If you pushed an wrong commit, on a non protected branch you can undo it reseting the HEAD to the last desired commit or reverting the wrong commits and forcing the push then. But protected branches does not allow force pushing. What's the way to fix it on this case?
Edit: The specified (rigtht) commit is not a merge.
Locally on the command line, you can use the git revert command to revert changes. This will work on both your protected branch and a downstream branch.
reverting the wrong commit
git revert SHA-1
git commit ....
git push origin <branch>
If your branch is protected and you can't perform a git push -f ...
the you you can simply execute a revert
.
git revert
Revert some existing commits
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With