Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Completely override a previous git commit

Tags:

git

My colleague has pushed to our git repository a mistake. I wish to commit some updated code, but I had not git pulled and as a result am 1 commit behind the HEAD. How can I ignore his changes completely and override his mistake if I am behind?

like image 626
pqn Avatar asked Jul 26 '11 01:07

pqn


1 Answers

You can force a push like the other answer suggests, but a safer way is to go ahead and pull his changes, then git revert his commit, which will completely undo all his changes. This doesn't run the risk of unintentionally losing changes:

git pull
git revert <treeish naming his commit>
git push
like image 50
Ryan Stewart Avatar answered Sep 26 '22 19:09

Ryan Stewart