# Git Cheatsheet ## Metadata **Status**:: #x **Zettel**:: #zettel/fleeting **Created**:: [[2025-11-15]] **Parent**:: [[♯ Cheatsheets]] [[♯ Git]] ## Log ### Copy Commit Message ``` git log -1 --format=%B <commit_hash> ``` Or, equivalently: ``` git show -s --format=%B <commit_hash> ``` ## Diff ### Override Diff Context Lines ``` GIT_DIFF_OPTS="-u7" git diff ... ``` ## Undo ### Discard Unstaged Changes ``` git restore <file> ``` Same as `git restore -W` and `git checkout -- <file>` ### Discard Uncommitted Changes ``` git restore -S -W <file> ``` ### Unstage ``` git restore -S <file> ``` ### Undo Temporary Commits Keep files staged: ``` git reset --soft <LAST-FORMAL-COMMIT> ``` Unstage files as well: ``` git reset <LAST-FORMAL-COMMIT> ``` Commit with original commit message: ``` git commit --reuse-message=HEAD@{1} ```