Elena' s AI Blog

Reverting Commits in GitHub

26 Aug 2022 (updated: 24 Aug 2026) / 14 minutes to read

Elena Daehnhardt

Reverting Commits in GitHub


TL;DR:
  • 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.

Previous: Part 7 — Debugging Git Commits: Finding Exactly What Broke

Next: Part 10 — Restoring deleted files in Git

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?

Git Fork-and-Pull-Request Workflow Setup

🔒 Subscribe to keep reading.

git reset vs git revert: When to Use Each

🔒 Subscribe to keep reading.

An example

🔒 Subscribe to keep reading.

Conclusion: reset vs revert vs rebase for Undoing Commits

🔒 Subscribe to keep reading.

References

🔒 Subscribe to keep reading.

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):

Already a subscriber? Use the magic link from your last newsletter, or reset your password.

New subscribers get an inbox mail: Set a password to unlock articles. The form does not log you in — use the same email afterwards.

desktop bg dark

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/
All Posts