git stash push -m "WIP before review"Messages make stash history much easier to understand in long-running repositories.
Temporary work preservation, multi-worktree workflows, cleanup commands, and conflict-resolution reuse.
Save, inspect, apply, branch from, and manage stashes.
git stash push -m "WIP before review"Messages make stash history much easier to understand in long-running repositories.
git stash push --keep-index -m "stash unstaged only"Useful when you want to test or commit only what is staged while setting aside unrelated work.
git stash push -m "stash selected files" -- path/to/file another/fileAdvanced stash usage for partial working tree preservation.
git stash list --statHelpful when you have many stashes and need a quick overview of their scope.
git stash show -p stash@{0}Useful before applying or branching from an older stash.
git stash branch recovered-wip stash@{0}Very useful when a stash no longer applies cleanly on the current branch but should become dedicated work.
Maintain multiple working directories from one repository.
git worktree listThe first command to run when managing multiple checkouts from the same repository.
git worktree add --detach ../investigation <commit_sha>Useful for quick historical investigation without disturbing active branches.
git worktree add -b hotfix ../hotfixA fast way to spin up a new isolated working directory for urgent work.
git worktree lock ../feature --reason "USB drive worktree"Useful when the worktree lives on a removable or temporarily unavailable path.
git worktree pruneHelpful after manually deleting worktree directories outside Git.
git worktree remove --force ../featureUse `--force` only when the worktree has local changes or other blockers and you intentionally want it removed.
Remove untracked files safely and recover from build clutter.
git clean -nAlways preview before cleaning. This is the safest habit for `git clean`.
git clean -fDeletes untracked files only, not directories or ignored files.
git clean -fdCommon when resetting a repository after generated build artifacts and local temp directories.
git clean -fdxVery destructive in projects with ignored local configs or build outputs. Use carefully.
git clean -iSafer than force-cleaning when you want more control over what gets removed.
Record and reuse conflict resolutions across merges and rebases.
git config --global rerere.enabled trueExcellent for repeated rebases, repeated cherry-picks, or long-running branches that see the same conflict patterns.
git rerere diffUseful when verifying that rerere recorded the intended resolution.
git rerere clearHelpful if rerere recorded an incorrect or unwanted resolution pattern.