Skip to main content

6.12 Stashing

Also see the git-stash(1) manpage.

z     (magit-stash)​

This transient prefix command binds the following suffix commands along with the appropriate infix arguments and displays them in a temporary buffer until a suffix is invoked.

z z     (magit-stash-both)​

Create a stash of the index and working tree. Untracked files are included according to infix arguments. One prefix argument is equivalent to --include-untracked while two prefix arguments are equivalent to --all.

z i     (magit-stash-index)​

Create a stash of the index only. Unstaged and untracked changes are not stashed.

z w     (magit-stash-worktree)​

Create a stash of unstaged changes in the working tree. Untracked files are included according to infix arguments. One prefix argument is equivalent to --include-untracked while two prefix arguments are equivalent to --all.

z x     (magit-stash-keep-index)​

Create a stash of the index and working tree, keeping index intact. Untracked files are included according to infix arguments. One prefix argument is equivalent to --include-untracked while two prefix arguments are equivalent to --all.

z Z     (magit-snapshot-both)​

Create a snapshot of the index and working tree. Untracked files are included according to infix arguments. One prefix argument is equivalent to --include-untracked while two prefix arguments are equivalent to --all.

z I     (magit-snapshot-index)​

Create a snapshot of the index only. Unstaged and untracked changes are not stashed.

z W     (magit-snapshot-worktree)​

Create a snapshot of unstaged changes in the working tree. Untracked files are included according to infix arguments. One prefix argument is equivalent to --include-untracked while two prefix arguments are equivalent to --all-.

z a     (magit-stash-apply)​

Apply a stash to the working tree. Try to preserve the stash index. If that fails because there are staged changes, apply without preserving the stash index.

z p     (magit-stash-pop)​

Apply a stash to the working tree and remove it from stash list. Try to preserve the stash index. If that fails because there are staged changes, apply without preserving the stash index and forgo removing the stash.

z k     (magit-stash-drop)​

Remove a stash from the stash list. When the region is active, offer to drop all contained stashes.

z v     (magit-stash-show)​

Show all diffs of a stash in a buffer.

z b     (magit-stash-branch)​

Create and checkout a new BRANCH from STASH. The branch starts at the commit that was current when the stash was created.

z B     (magit-stash-branch-here)​

Create and checkout a new BRANCH using magit-branch with the current branch or HEAD as the starting-point. Then apply STASH, dropping it if it applies cleanly.

z f     (magit-stash-format-patch)​

Create a patch from STASH.

k     (magit-stash-clear)​

Remove all stashes saved in REF’s reflog by deleting REF.

z l     (magit-stash-list)​

List all stashes in a buffer.

user option magit-stashes-margin​

This option specifies whether the margin is initially shown in stashes buffers and how it is formatted.

The value has the form (INIT STYLE WIDTH AUTHOR AUTHOR-WIDTH).

  • If INIT is non-nil, then the margin is shown initially.
  • STYLE controls how to format the author or committer date. It can be one of age (to show the age of the commit), age-abbreviated (to abbreviate the time unit to a character), or a string (suitable for format-time-string) to show the actual date. Option magit-log-margin-show-committer-date controls which date is being displayed.
  • WIDTH controls the width of the margin. This exists for forward compatibility and currently the value should not be changed.
  • AUTHOR controls whether the name of the author is also shown by default.
  • AUTHOR-WIDTH has to be an integer. When the name of the author is shown, then this specifies how much space is used to do so.