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.
Keep staged changes in the index and stash the rest.
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.
See stash entries and a compact summary of their changes.
git stash list --statHelpful when you have many stashes and need a quick overview of their scope.
Inspect the actual diff stored in a stash entry.
git stash show -p stash@{0}Useful before applying or branching from an older stash.
Check out a new branch and apply a stash there.
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.
Check out a specific commit in a new working tree.
git worktree add --detach ../investigation <commit_sha>Useful for quick historical investigation without disturbing active branches.
Add a worktree and create a new branch from current HEAD.
git worktree add -b hotfix ../hotfixA fast way to spin up a new isolated working directory for urgent work.
Prevent a worktree from being pruned or accidentally removed.
git worktree lock ../feature --reason "USB drive worktree"Useful when the worktree lives on a removable or temporarily unavailable path.
Clean up references to missing worktree directories.
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.
Remove untracked files and directories.
git clean -fdCommon when resetting a repository after generated build artifacts and local temp directories.
Remove ignored and untracked files and 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.