Git Rollback to Specific Commit

Published: October 31, 2025

← Back to Home

We all love Git: it’s a fantastic source control tool and it helps us undo mistakes (among other very useful things). Occasionally I need to roll back a branch to a specific commit. I don’t do it often, but I’m grateful it’s an option. Here are my notes on how to do it - hopefully this is helpful to someone:

A note of caution: this changes your commit history — use these commands judiciously.

Before you begin, ensure you’re on the branch you want to change. Run the git reset --hard command with the commit hash you want to roll back to, then force-push to the remote repository. Simple. Dangerous!

git reset --hard [commit-id-going-back-to]
git push -f

Happy Coding!