Home Explore Blog CI



git

1st chunk of `Documentation/git-stash.adoc`
018cb81028f33573e1c0111c25bb391071e017369ee0806e0000000100000fa4
git-stash(1)
============

NAME
----
git-stash - Stash the changes in a dirty working directory away

SYNOPSIS
--------
[verse]
'git stash' list [<log-options>]
'git stash' show [-u | --include-untracked | --only-untracked] [<diff-options>] [<stash>]
'git stash' drop [-q | --quiet] [<stash>]
'git stash' pop [--index] [-q | --quiet] [<stash>]
'git stash' apply [--index] [-q | --quiet] [<stash>]
'git stash' branch <branchname> [<stash>]
'git stash' [push [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet]
	     [-u | --include-untracked] [-a | --all] [(-m | --message) <message>]
	     [--pathspec-from-file=<file> [--pathspec-file-nul]]
	     [--] [<pathspec>...]]
'git stash' save [-p | --patch] [-S | --staged] [-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>

DESCRIPTION
-----------

Use `git stash` when you want to record the current state of the
working directory and the index, but want to go back to a clean
working directory.  The command saves your local modifications away
and reverts the working directory to match the `HEAD` commit.

The modifications stashed away by this command can be listed with
`git stash list`, inspected with `git stash show`, and restored
(potentially on top of a different commit) with `git stash apply`.
Calling `git stash` without any arguments is equivalent to `git stash push`.
A stash is by default listed as "WIP on 'branchname' ...", but
you can give a more descriptive message on the command line when
you create one.

The latest stash you created is stored in `refs/stash`; older
stashes are found in the reflog of this reference and can be named using
the usual reflog syntax (e.g. `stash@{0}` is the most recently
created stash, `stash@{1}` is the one before it, `stash@{2.hours.ago}`
is also possible). Stashes may also be referenced by specifying just the
stash index (e.g. the integer `n` is equivalent to `stash@{n}`).

COMMANDS
--------

push [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [(-m|--message) <message>] [--pathspec-from-file=<file> [--pathspec-file-nul]] [--] [<pathspec>...]::

	Save your local modifications to a new 'stash entry' and roll them
	back to HEAD (in the working tree and in the index).
	The <message> part is optional and gives
	the description along with the stashed state.
+
For quickly making a snapshot, you can omit "push".  In this mode,
non-option arguments are not allowed to prevent a misspelled
subcommand from making an unwanted stash entry.  The two exceptions to this
are `stash -p` which acts as alias for `stash push -p` and pathspec elements,
which are allowed after a double hyphen `--` for disambiguation.

save [-p|--patch] [-S|--staged] [-k|--[no-]keep-index] [-u|--include-untracked] [-a|--all] [-q|--quiet] [<message>]::

	This option is deprecated in favour of 'git stash push'.  It
	differs from "stash push" in that it cannot take pathspec.
	Instead, all non-option arguments are concatenated to form the stash
	message.

list [<log-options>]::

	List the stash entries that you currently have.  Each 'stash entry' is
	listed with its name (e.g. `stash@{0}` is the latest entry, `stash@{1}` is
	the one before, etc.), the name of the branch that was current when the
	entry was made, and a short description of the commit the entry was
	based on.
+
----------------------------------------------------------------
stash@{0}: WIP on submit: 6ebd0e2... Update git-stash documentation
stash@{1}: On master: 9cc0589... Add git-stash
----------------------------------------------------------------
+
The command takes options applicable to the 'git log'
command to control what is shown and how. See linkgit:git-log[1].

show [-u|--include-untracked|--only-untracked] [<diff-options>] [<stash>]::

	Show the changes recorded in the stash entry as a diff

Title: Git Stash Documentation
Summary
The git-stash command is used to temporarily save and revert changes in a working directory, allowing users to switch branches or commit changes without losing their current work. It provides various options, including push, save, list, show, drop, pop, apply, branch, and clear, each serving a specific purpose in managing stash entries, such as saving local modifications, listing existing stashes, and applying or removing them.