Skip to content

Undo and Fix

Fenêtre de terminal
git checkout -- file.txt # discard uncommitted changes
Fenêtre de terminal
git reset --soft HEAD~1 # keep files staged
git reset --hard HEAD~1 # completely remove changes
Fenêtre de terminal
git revert abc123
Fenêtre de terminal
git stash
git stash apply

  • Use git reset only locally (dangerous if shared).
  • Prefer git revert to undo changes in a collaborative project.
  • Use stash to pause ongoing work.