DEV Community

Matthew LaFalce
Matthew LaFalce

Posted on

How To: Undo the Last Commit From Your Remote Git Repository

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

First you can use the following command to undo the last commit locally.

git reset HEAD^
Enter fullscreen mode Exit fullscreen mode

Then you are able to use the following command to force push the local commit which was reverted to the remote git repository.

git push origin +HEAD
Enter fullscreen mode Exit fullscreen mode

Discussion (0)