Name
stash
Synopsis
git stash git stash list git stash show [stashid
] git stash apply [stashid
]
Save, list, or reapply the set of uncommitted changes from a work tree and index.
This command takes one of four forms:
- git stash
Save the current set of uncommitted changes and undo them. The index and work tree are reset to match HEAD.
- git stash list
Show the list of all stashes that have previously been saved.
- git stash show [stashid]
Show the exact set of changes that are saved as stashid. If stashid is omitted, uses the most recently saved changes.
- git stash apply [stashid]
Brings back the changes from the given stashid and applies them to the current index and work tree. If stashid is omitted, uses the most recently saved changes.
Examples
To save the current set of uncommitted changes, switch branches, and apply those changes to the new branch:
$git stash
Saved working directory and index state "WIP on master: 44951b7... Say hello" (To restore them type "git stash apply") HEAD is now at 44951b7 Say hello $git checkout feature1
Switched to a new branch "feature1" $git stash apply
Removed test1.c
Get Linux in a Nutshell, 6th Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.