Mid From PDF Version Control Git & GitHub

How do you undo a commit that has already been pushed?

Short answer: If a commit has been pushed to a shared branch, the safest way is to revert it — not remove it.

Explain a bit more

git revert <commit-hash> This creates a new commit that undoes the changes from the old one, without rewriting history. Example: If you pushed a buggy commit that broke the login page, git revert creates a new commit that removes those buggy changes while keeping the history intact. ⚠ Avoid git reset on shared branches because it rewrites history — it can mess up others’ work.

Real-world example (ShopNest)

Prefer clear commits: fix(cart): prevent negative quantities instead of update.

Say this in the interview

  1. Define — one clear sentence (the short answer above).
  2. Example — relate it to a project like ShopNest or your real work.
  3. Trade-off — when you would not use it.
Toolliyo Assistant
Ask about tutorials, ebooks, training, pricing, mentor services, and support. I use public site content only—not admin or internal tools.

care@toolliyo.com

Need callback? Share your details