Reputation: 7034
Which command do i use to revert the changes made by the last commit? The commit was already pushed to the remote server.
Upvotes: 1
Views: 1990
Reputation: 121790
It depends what you mean by reverting. You want to either do a "real" revert, ie creating another commit which is the exact opposite (diff-wise) of the commit you want to revert, or completely forgetting about the commit.
In the first case, as mentioned: git revert HEAD
. In the commit message, mention the reason for the revert. Then push the result.
In the second case, git reset --hard HEAD~1
. However, you'll need to force the push. If you're on branch master
(and your remote is called origin
), that would be git push origin +master
.
Upvotes: 2
Reputation: 190976
git revert HEAD
That will back out the most recent commit. Then just push it up.
You can replace HEAD
with the revision you want out.
Upvotes: 5