Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| git_stash [2019/02/20 16:47] – [SYNOPSIS] rpjday | git_stash [2019/02/26 19:18] (current) – [git stash branch] rpjday | ||
|---|---|---|---|
| Line 19: | Line 19: | ||
| </ | </ | ||
| - | ===== git stash push ===== | + | ===== Basic stash operations ===== |
| + | |||
| + | ==== git stash push ==== | ||
| Save both the unstaged and staged content in a new stash: | Save both the unstaged and staged content in a new stash: | ||
| Line 32: | Line 34: | ||
| $ git stash list | $ git stash list | ||
| stash@{0}: WIP on master: 40e196a906d9 Merge git:// | stash@{0}: WIP on master: 40e196a906d9 Merge git:// | ||
| + | $ | ||
| + | </ | ||
| + | |||
| + | Significant options for '' | ||
| + | |||
| + | * ['' | ||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | ==== git stash show ==== | ||
| + | |||
| + | By default, show most recent stash: | ||
| + | |||
| + | < | ||
| + | $ git stash show | ||
| + | | ||
| + | | ||
| + | 2 files changed, 8 insertions(+) | ||
| + | $ | ||
| + | </ | ||
| + | |||
| + | < | ||
| + | $ git stash show stash@{0} | ||
| + | | ||
| + | | ||
| + | 2 files changed, 8 insertions(+) | ||
| + | $ | ||
| + | </ | ||
| + | |||
| + | Show the actual content with '' | ||
| + | |||
| + | < | ||
| + | $ git stash show -p | ||
| + | diff --git a/ | ||
| + | index 41ce5f4ad838..e0c46b96e2d3 100644 | ||
| + | --- a/ | ||
| + | +++ b/ | ||
| + | @@ -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 '' | ||
| + | |||
| + | < | ||
| + | $ git stash pop --index | ||
| + | </ | ||
| + | |||
| + | ==== Throwing away stashes ==== | ||
| + | |||
| + | < | ||
| + | $ git stash drop | ||
| + | $ git stash drop stash@{1} | ||
| + | $ git stash clear | ||
| + | </ | ||
| + | |||
| + | ==== Working with pathspecs ==== | ||
| + | |||
| + | '' | ||
| + | |||
| + | < | ||
| + | $ git stash push -- goodstuff/ | ||
| + | </ | ||
| + | |||
| + | ==== git stash branch ==== | ||
| + | |||
| + | < | ||
| + | Creates and checks out a new branch named < | ||
| + | starting from the commit at which the < | ||
| + | originally created, applies the changes recorded in < | ||
| + | to the new working tree and index. If that succeeds, and | ||
| + | < | ||
| + | then drops the < | ||
| + | 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. | ||
| + | </ | ||
| + | |||
| + | ===== How stashes are implemented ===== | ||
| + | |||
| + | Stashes are represented by three new commits in the object store, referenced by stash pointers only: | ||
| + | |||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | The //full// content of the stash: | ||
| + | |||
| + | < | ||
| + | $ git diff stash@{0}^1 stash@{0} | ||
| + | diff --git a/README b/README | ||
| + | index 669ac7c32292..9c61fa8595e9 100644 | ||
| + | --- a/README | ||
| + | +++ b/README | ||
| + | @@ -1,3 +1,8 @@ | ||
| + | +staged stuff | ||
| + | + | ||
| + | + | ||
| + | + | ||
| + | + | ||
| + | Linux kernel | ||
| + | | ||
| + | |||
| + | @@ -16,3 +21,8 @@ several of them using the Restructured Text markup notation. | ||
| + | | ||
| + | | ||
| + | the problems which may result by upgrading your kernel. | ||
| + | + | ||
| + | + | ||
| + | + | ||
| + | +unstaged stuff | ||
| + | + | ||
| + | $ | ||
| + | </ | ||
| + | |||
| + | The staged content only: | ||
| + | |||
| + | < | ||
| + | $ git diff stash@{0}^1 stash@{0}^2 | ||
| + | diff --git a/README b/README | ||
| + | index 669ac7c32292..ded86dccf25a 100644 | ||
| + | --- a/README | ||
| + | +++ b/README | ||
| + | @@ -1,3 +1,8 @@ | ||
| + | +staged stuff | ||
| + | + | ||
| + | + | ||
| + | + | ||
| + | + | ||
| + | Linux kernel | ||
| + | | ||
| + | |||
| + | $ | ||
| + | </ | ||
| + | |||
| + | Finally, the unstaged content: | ||
| + | |||
| + | < | ||
| + | $ git diff stash@{0}^2 stash@{0} | ||
| + | diff --git a/README b/README | ||
| + | index ded86dccf25a..9c61fa8595e9 100644 | ||
| + | --- a/README | ||
| + | +++ b/README | ||
| + | @@ -21,3 +21,8 @@ several of them using the Restructured Text markup notation. | ||
| + | | ||
| + | | ||
| + | the problems which may result by upgrading your kernel. | ||
| + | + | ||
| + | + | ||
| + | + | ||
| + | +unstaged stuff | ||
| + | + | ||
| $ | $ | ||
| </ | </ | ||