Revert Git commits: use 'git reset' for local changes, 'git revert' for shared commits (safer), 'git rebase -i' to rewrite history. Never rewrite public history—use revert instead.
📚 This post is part of the "Git Survival Guide" series
How to Undo Git Commits with reset, revert, and rebase
In my previous posts “GIT in 10 minutes” and Collaboration in GitHub, I have covered
the basics of Git setup, a few workflow commands to get started using Git (version control system), and collaborative work, including operations with forks and pull requests.
As promised, I will go into more detail about working with Git repositories.
Here, I focus on reverting your changes. Sometimes it’s good to step back and think about something different, right?
Still in this guide
Git Fork-and-Pull-Request Workflow Setup
git reset vs git revert: When to Use Each
An example
Conclusion: reset vs revert vs rebase for Undoing Commits
References
You've hit a Deep Dive tutorial.
I spend dozens of hours researching, coding, and breaking things to write these guides. This content is free, but reserved for my subscriber community. Drop your email below to unlock this guide (and all past/future deep dives):
Full content temporarily unavailable — refresh in a moment
You're in
I'll send weekly notes on AI tools, Python, and what I'm actually building. Check your inbox for Set a password to unlock articles — the form does not log you in.
New subscribers get an inbox mail: Set a password to unlock articles. The form does not log you in — use the same email afterwards.
References
About Elena
Elena, a PhD in Computer Science, simplifies AI concepts and helps you use machine learning.
Citation
Elena Daehnhardt. (2022) 'Reverting Commits in GitHub', daehnhardt.com, 26 August 2022. Available at: https://daehnhardt.com/blog/2022/08/26/git-reverting-commits/
Want the Git cheatsheet and the Fantastic AI 2026 toolkit in your inbox?
Git Commands & WorkflowFantastic AI: The 2026 ToolkitVibe Coding Checklist
+4more free gifts
You're in
I'll send weekly notes on AI tools, Python, and what I'm actually building. Check your inbox for Set a password to unlock articles — the form does not log you in.