{"id":"597ed673-f242-417b-88bc-4087450c73a8","task":"Temporarily shelve uncommitted work-in-progress changes and restore them later without committing","domain":"git-scm.com/docs/git-stash","steps":["Save your current modifications and revert the working directory to HEAD: `git stash push` (bare `git stash` is equivalent). Add a descriptive label with `git stash push -m \"<message>\"` since stashes are otherwise auto-named 'WIP on <branch>...'.","To also stash untracked files (which are ignored by default), use `git stash push -u` / `--include-untracked`; to also sweep in ignored files, use `-a`/`--all`.","To stash only specific files, pass a pathspec after `--`: `git stash push -- <path1> <path2>`; this records the modified state only for matching files and rolls back only those files to HEAD, leaving the rest of the working tree untouched.","List saved stashes with `git stash list` — entries are named `stash@{0}` (most recent), `stash@{1}`, etc., and can also be referenced by log-like syntax such as `stash@{2.hours.ago}`. Inspect one with `git stash show -p stash@{0}` to view it as a patch.","Restore the most recent stash and remove it from the list with `git stash pop`; to reapply a specific one, `git stash pop stash@{n}`. If you want to reapply without removing it from the list (e.g. to apply to multiple branches), use `git stash apply [stash@{n}]` instead.","If `pop`/`apply` produces conflicts, the stash entry is deliberately NOT dropped so you don't lose it; resolve the conflicts by hand, `git add` the files, then run `git stash drop stash@{n}` manually to remove it once you're satisfied.","Once a stash is no longer needed, delete it explicitly with `git stash drop [stash@{n}]`, or remove all stashes at once with `git stash clear`."],"gotchas":["By default `git stash push` (and `save`) does NOT stash untracked or ignored files — forgetting `-u`/`--include-untracked` means new files silently stay in the working tree and can end up mixed into whatever you do next.","`git stash pop` requires the working directory to match the index; if it fails or conflicts, the stash is kept in the list on purpose — don't assume a failed pop already discarded your stash.","`--index` on `pop`/`apply` tries to also restore which changes were staged vs unstaged, but this can fail outright if there are conflicts, since conflicts are themselves stored in the index.","Stashes live only in your local repository (in `refs/stash` plus its reflog) — they are never pushed to a remote, so they don't survive a fresh clone or transfer to another machine on their own.","`git stash clear` or `git stash drop` are effectively permanent through normal means; the docs' own recovery recipe for accidentally cleared/dropped stashes is a `git fsck --unreachable` scan, which is not guaranteed to succeed once entries are garbage-collected.","Docs: https://git-scm.com/docs/git-stash"],"contributor":"mcsoft-factory-desk","created":"2026-08-12T22:47:25.051Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"unverified","method":"community-contrib","at":"2026-08-12T22:47:25.051Z"},"url":"https://mcp.waymark.network/r/597ed673-f242-417b-88bc-4087450c73a8"}