This is an old revision of the document!
Overview
Basic operation of git stash, which allows you to save uncommitted work, and recover it later.
SYNOPSIS
git stash list [<options>]
git stash show [<stash>]
git stash drop [-q|--quiet] [<stash>]
git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
git stash branch <branchname> [<stash>]
git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
[-u|--include-untracked] [-a|--all] [-m|--message <message>]
[--] [<pathspec>...]]
git stash clear
git stash create [<message>]
git stash store [-m|--message <message>] [-q|--quiet] <commit>
git stash push
Save both the unstaged and staged content in a new stash:
$ git stash push
then display the current list of stashes:
$ git stash list
stash@{0}: WIP on master: 40e196a906d9 Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
$
Significant options for git stash push:
- [
-m,--message]: Add an informative stashing message --keep-index: Remember what was already staged versus what wasn't--include-untracked: Stash untracked, unignored files, then clean--all: Stash all untracked files, including ignored ones, then clean
git stash show
By default, show most recent stash:
$ git stash show MAINTAINERS | 4 ++++ README | 4 ++++ 2 files changed, 8 insertions(+) $
$ git stash show stash@{0}
MAINTAINERS | 4 ++++
README | 4 ++++
2 files changed, 8 insertions(+)
$
Show the actual content:
$ git stash show -p
diff --git a/MAINTAINERS b/MAINTAINERS
index 41ce5f4ad838..e0c46b96e2d3 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1,3 +1,7 @@
+uncached stuff
+
+
+
List of maintainers and how to submit kernel changes
diff --git a/README b/README
index 669ac7c32292..9b80a4811f05 100644
--- a/README
+++ b/README
@@ -1,3 +1,7 @@
+cached stuff
+
+
+
Linux kernel
============
$
git stash pop/apply
Pop/apply the most recent stash, or a specified stash:
$ git stash pop
$ git stash pop stash@{1}
$ git stash apply
Use --keep-index to restore the cached content in the index:
$ git stash pop --index
Throwing away stashes
$ git stash drop
$ git stash drop stash@{1}
$ git stash clear
Working with pathspecs
git stash push supports pushing partial changes using a pathspec:
$ git stash push -- goodstuff/
git stash branch
Creates and checks out a new branch named <branchname>
starting from the commit at which the <stash> was
originally created, applies the changes recorded in <stash>
to the new working tree and index. If that succeeds, and
<stash> is a reference of the form stash@{<revision>}, it
then drops the <stash>. When no <stash> is given, applies
the latest one.
This is useful if the branch on which you ran git stash
push has changed enough that git stash apply fails due to
conflicts. Since the stash entry is applied on top of the
commit that was HEAD at the time git stash was run, it
restores the originally stashed state with no conflicts.