tldr/pages/common/git-stash.md

28 lines
651 B
Markdown
Raw Normal View History

2013-12-09 11:12:24 +00:00
# git stash
> Stash local Git changes in a temporary area.
2013-12-09 11:12:24 +00:00
2016-09-01 19:01:07 +01:00
- Stash current changes, except new files:
2013-12-09 11:12:24 +00:00
2016-09-01 19:01:07 +01:00
`git stash [save {{optional_stash_message}}]`
2013-12-09 11:12:24 +00:00
2016-09-01 19:01:07 +01:00
- Stash current changes, including new/untracked files:
2013-12-09 11:12:24 +00:00
2016-09-01 19:01:07 +01:00
`git stash -u`
2013-12-09 11:12:24 +00: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`
- Apply a stash (default is the latest, named stash@{0}):
2013-12-09 11:12:24 +00:00
`git stash apply {{optional_stash_name_or_commit}}`
2013-12-09 11:12:24 +00:00
- Apply a stash (default is stash@{0}), and remove it from the list if applying doesn't cause conflicts:
2013-12-09 11:12:24 +00:00
`git stash pop {{optional_stash_name}}`
2014-05-24 21:05:35 +01:00
- Drop a stash (default is stash@{0}):
2014-05-24 21:05:35 +01:00
`git stash drop {{optional_stash_name}}`