undo.sh — bash — 120×36
tmux 0:undo*
$ find-undo
# type a keyword to filter recipes · 37 total
══════════════════════════════════════════════════════════════════
$ cat git/undo.md

[ GIT ] — undo for version control

# How do I undo the last commit but keep my changes staged?
$ git reset --soft HEAD~1
→ Moves HEAD back one commit. Index and working tree untouched.
→ Your changes remain staged, ready to recommit.
# Discard ALL local changes and reset to remote
$ git reset --hard origin/main
DESTRUCTIVE — uncommitted work is lost. There is no "trash".
# Undo a commit that's already pushed (preserves history)
$ git revert <sha>
→ Creates a new commit that inverts <sha>.
→ Safe for shared branches: rewrites nothing.
# Throw away changes to a single file
$ git restore path/to/file.txt
→ Replaces the working-tree copy with the indexed version.
# I accidentally dropped a stash — can I get it back?
$ git fsck --no-reflog | awk '/dangling commit/ {print $3}'
→ Lists dangling commits. Try git show <sha> on each.
→ Recover with git stash apply <sha>.
# I force-pushed and lost my branch — help
$ git reflog | grep 'feature-x'
→ The reflog remembers every HEAD movement for ~90 days.
git reset --hard <sha> restores the branch tip.
══════════════════════════════════════════════════════════════════
══════════════════════════════════════════════════════════════════
$
[undo] 0:bash* git/undo.md "undo.sh" — --:--:--