DEV Community

Cover image for How to undo the last commit from a remote git repository?
MELVIN GEORGE
MELVIN GEORGE

Posted on • Originally published at melvingeorge.me

How to undo the last commit from a remote git repository?

Originally posted here!

To undo the last commit from a remote git repository, you can use the git reset command.

First, you can use the,

git reset HEAD^
Enter fullscreen mode Exit fullscreen mode

command. This will undo the last commit locally.

Then you can use the,

git push origin +HEAD
Enter fullscreen mode Exit fullscreen mode

command to force push the local commit which was reverted to the remote git repository.

Feel free to share if you found this useful 😃.


Top comments (0)