Remove the last commit from the remote git repository

In this short article, show you how to remove the last commit from the git repository.

Here, we will see three simple steps to remove the last commit from the local and remote git repository.

Steps to remove the last commit from the remote git repository

  1. Check the logs
  2. Remove the last commit from the local branch
  3. Update remote repository

1. Check the logs

First of all, check your local commit with messages before removing the last commit. Run the following command to check the logs in one line.

2. Remove the last commit from the local branch

Now, Run the following command to remove the last commit and discard the changes from the local branch.

Checkout the different ways to Undo commit before push in Git.

3. Update remote repository

At last, we will update the files and again need to push with force. It will delete the previous commit and keep a new one on the remote git repository.

Now you can check the logs to verify the commit in the git repository.

I hope you find this article helpful.
Thank you for reading. Happy Coding..!! 🙂

If you found value in this article,
you can support us by buying me a coffee! ☕

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *