Git – Revert to Specific Commit – Local & Pushed

In Git we can gracefully revert all changes to the specific commit without using the potentially dangerous git reset command.

In this note i am showing how to undo local changes by making a rollback to the specific commit and how to revert a commit that has already been pushed to remote.

Cool Tip: Revert a file to the previous commit! Read more →

Git – Revert to Specific Commit

Find the specific commit you want to revert all changes to:

$ git log --oneline

Rollback all changes to that old commit:

$ git checkout be9055b .

Note: The dot (.) after the branch name is mandatory.

Add the changes to the staging area and commit them:

$ git add -A
$ git commit -m "Revert commit: be9055b"

Once the local rollback is done, you can revert the already pushed commits, by pushing a new revision with the reverted changes to the remote Git repository:

$ git push

Cool Tip: Clear Git history by removing all commits! Read more →

Recommended Book
devops

This is a must-read for anyone who wants to understand, explain and implement DevOps culture, process and tools for high performance development and operations.

All DevOps practices in a single place - organisational, cultural and technical. Lots of exceptional case studies.

Increase profitability, elevate work culture, and exceed productivity goals through DevOps practices.