moves / git http / git undo

Undoing things in git

Pick by blast radius: `restore` for files, `reset --soft` to re-do a commit message, `revert` for anything already pushed, `reflog` when you think work is gone.

#git#reset#revert#reflog
bash
git restore src/app.ts           # discard local file changes
git restore --staged src/app.ts  # unstage, keep changes
git commit --amend               # fix the last commit
git reset --soft HEAD~1          # undo commit, keep changes staged
git revert <sha>                 # safe undo of a pushed commit
git reflog                       # find "lost" commits

Related

WWADD — Moves. Stacks. Judgment calls.

FREE REFERENCE · NO LOGIN · NO TRACKING