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

matthewlafalce

Matthew LaFalce

Posted on January 17, 2022

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
πŸ’– πŸ’ͺ πŸ™… 🚩
matthewlafalce
Matthew LaFalce

Posted on January 17, 2022

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related