2013-12-09 11:12:24 +00:00
|
|
|
# git stash
|
|
|
|
|
2016-01-07 17:31:27 +00:00
|
|
|
> Stash local Git changes in a temporary area.
|
2019-06-03 01:06:36 +01:00
|
|
|
> More information: <https://git-scm.com/docs/git-stash>.
|
2013-12-09 11:12:24 +00:00
|
|
|
|
2024-08-12 16:33:23 +01:00
|
|
|
- Stash current changes with a [m]essage, except new (untracked) files:
|
2013-12-09 11:12:24 +00:00
|
|
|
|
2024-08-12 16:33:23 +01:00
|
|
|
`git stash push --message {{optional_stash_message}}`
|
2013-12-09 11:12:24 +00:00
|
|
|
|
2024-08-12 16:33:23 +01:00
|
|
|
- Stash current changes, including new ([u]ntracked) files:
|
2013-12-09 11:12:24 +00:00
|
|
|
|
2024-08-12 16:33:23 +01:00
|
|
|
`git stash --include-untracked`
|
2013-12-09 11:12:24 +00:00
|
|
|
|
2024-08-12 16:33:23 +01:00
|
|
|
- Interactively select [p]arts of changed files for stashing:
|
2016-09-28 08:46:15 +01:00
|
|
|
|
2024-08-12 16:33:23 +01:00
|
|
|
`git stash --patch`
|
2016-09-28 08:46:15 +01:00
|
|
|
|
2016-09-01 19:01:07 +01:00
|
|
|
- List all stashes (shows stash name, related branch and message):
|
2013-12-09 11:12:24 +00:00
|
|
|
|
|
|
|
`git stash list`
|
|
|
|
|
2024-08-12 16:33:23 +01:00
|
|
|
- Show the changes as a [p]atch between the stash (default is `stash@{0}`) and the commit back when stash entry was first created:
|
2022-12-17 08:33:38 +00:00
|
|
|
|
2024-08-12 16:33:23 +01:00
|
|
|
`git stash show --patch {{stash@{0}}}`
|
2022-12-17 08:33:38 +00:00
|
|
|
|
2016-08-30 23:57:40 +01:00
|
|
|
- Apply a stash (default is the latest, named stash@{0}):
|
2013-12-09 11:12:24 +00:00
|
|
|
|
2016-08-30 23:57:40 +01:00
|
|
|
`git stash apply {{optional_stash_name_or_commit}}`
|
2013-12-09 11:12:24 +00:00
|
|
|
|
2022-12-17 08:33:38 +00:00
|
|
|
- Drop or apply a stash (default is stash@{0}) and remove it from the stash list if applying doesn't cause conflicts:
|
2013-12-09 11:12:24 +00:00
|
|
|
|
2016-08-30 23:57:40 +01:00
|
|
|
`git stash pop {{optional_stash_name}}`
|
2014-05-24 21:05:35 +01:00
|
|
|
|
2016-11-19 17:43:18 +00:00
|
|
|
- Drop all stashes:
|
|
|
|
|
|
|
|
`git stash clear`
|