Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

git undo commit on protected branch?

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.

like image 489
trz Avatar asked Mar 12 '16 13:03

trz


People also ask

How do I revert a protected branch from a commit?

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.


1 Answers

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

like image 116
CodeWizard Avatar answered Sep 17 '22 10:09

CodeWizard