Stashing

Download git eBook

Syntax

  • 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 [save [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet] [-u|--include-untracked] [-a|--all] [<message>]]
  • git stash clear
  • git stash create [<message>]
  • git stash store [-m|--message <message>] [-q|--quiet] <commit>

Parameters

ParameterDetails
showShow the changes recorded in the stash as a diff between the stashed state and its original parent. When no <stash> is given, shows the latest one.
listList the stashes that you currently have. Each stash is listed with its name (e.g. stash@{0} is the latest stash, stash@{1} is the one before, etc.), the name of the branch that was current when the stash was made, and a short description of the commit the stash was based on.
popRemove a single stashed state from the stash list and apply it on top of the current working tree state.
applyLike pop, but do not remove the state from the stash list.
clearRemove all the stashed states. Note that those states will then be subject to pruning, and may be impossible to recover.
dropRemove a single stashed state from the stash list. When no <stash> is given, it removes the latest one. i.e. stash@{0}, otherwise <stash> must be a valid stash log reference of the form stash@{<revision>}.
createCreate a stash (which is a regular commit object) and return its object name, without storing it anywhere in the ref namespace. This is intended to be useful for scripts. It is probably not the command you want to use; see "save" above.
storeStore a given stash created via git stash create (which is a dangling merge commit) in the stash ref, updating the stash reflog. This is intended to be useful for scripts. It is probably not the command you want to use; see "save" above.

Remarks

Stashing allows us to have a clean working directory without losing any information. Then, it's possible to start working on something different and/or to switch branches.

Related Examples

Stats

842 Contributors: 25
Sunday, June 18, 2017
Licensed under: CC-BY-SA

Not affiliated with Stack Overflow
Rip Tutorial: info@zzzprojects.com

Download eBook