DevBolt
Processed in your browser. Your data never leaves your device.

Git Reset vs Revert — Undo Changes Safely

Both reset and revert undo changes, but they work very differently. Use the builder above to construct the right command with safe defaults.

GitCommand Builder

Build git commands visually or browse the cheat sheet. Select an operation, fill in parameters, and copy the result.

Tools/Git Command Builder

Initialize Repository

Create a new Git repository
Generated Command
git init

Quick Tips

  • Use git switch instead of git checkout for switching branches (Git 2.23+)
  • Prefer --force-with-lease over --force to avoid overwriting others' work
  • Use git reflog to recover lost commits

git reset — rewrite history

git reset moves the branch pointer backward, effectively removing commits from history. --soft keeps changes staged, --mixed (default) keeps changes unstaged, --hard discards everything. Because it rewrites history, only use reset on unpushed commits.

git revert — safe undo

git revert creates a new commit that undoes the changes from a previous commit. The original commit stays in history. This is safe to use on shared branches because it does not rewrite history. Use --no-edit to accept the default revert message.

Which should I use?

Use revert for commits that have been pushed to a shared branch. Use reset for local unpushed commits where you want a clean history. When in doubt, use revert — it is always safe.

Frequently Asked Questions

Can I undo a git reset?

Yes, using git reflog. Find the commit hash before the reset and run git reset --hard <hash>. Reflog keeps a history of HEAD changes for about 90 days.

What does git reset --soft do?

git reset --soft HEAD~1 undoes the last commit but keeps all changes staged. This is useful when you want to amend or restructure a commit without losing any work.

Related Generate Tools