Home Explore Blog CI



git

4th chunk of `Documentation/git-stash.adoc`
0e2a6baa0e9c1cf1cd89b2109d33d71ff64a8bf1cc0447670000000100000bc2
 `--literal-pathspecs`.

--pathspec-file-nul::
	This option is only valid for `push` command.
+
Only meaningful with `--pathspec-from-file`. Pathspec elements are
separated with NUL character and all other characters are taken
literally (including newlines and quotes).

-q::
--quiet::
	This option is only valid for `apply`, `drop`, `pop`, `push`,
	`save`, `store` commands.
+
Quiet, suppress feedback messages.

\--::
	This option is only valid for `push` command.
+
Separates pathspec from options for disambiguation purposes.

<pathspec>...::
	This option is only valid for `push` command.
+
The new stash entry records the modified states only for the files
that match the pathspec.  The index entries and working tree files
are then rolled back to the state in HEAD only for these files,
too, leaving files that do not match the pathspec intact.
+
For more details, see the 'pathspec' entry in linkgit:gitglossary[7].

<stash>::
	This option is only valid for `apply`, `branch`, `drop`, `pop`,
	`show` commands.
+
A reference of the form `stash@{<revision>}`. When no `<stash>` is
given, the latest stash is assumed (that is, `stash@{0}`).

DISCUSSION
----------

A stash entry is represented as a commit whose tree records the state
of the working directory, and its first parent is the commit at `HEAD`
when the entry was created.  The tree of the second parent records the
state of the index when the entry is made, and it is made a child of
the `HEAD` commit.  The ancestry graph looks like this:

            .----W
           /    /
     -----H----I

where `H` is the `HEAD` commit, `I` is a commit that records the state
of the index, and `W` is a commit that records the state of the working
tree.


EXAMPLES
--------

Pulling into a dirty tree::

When you are in the middle of something, you learn that there are
upstream changes that are possibly relevant to what you are
doing.  When your local changes do not conflict with the changes in
the upstream, a simple `git pull` will let you move forward.
+
However, there are cases in which your local changes do conflict with
the upstream changes, and `git pull` refuses to overwrite your
changes.  In such a case, you can stash your changes away,
perform a pull, and then unstash, like this:
+
----------------------------------------------------------------
$ git pull
 ...
file foobar not up to date, cannot merge.
$ git stash
$ git pull
$ git stash pop
----------------------------------------------------------------

Interrupted workflow::

When you are in the middle of something, your boss comes in and
demands that you fix something immediately.  Traditionally, you would
make a commit to a temporary branch to store your changes away, and
return to your original branch to make the emergency fix, like this:
+
----------------------------------------------------------------
# ... hack hack hack ...
$ git switch -c my_wip
$ git commit -a -m "WIP"
$ git switch master
$ edit emergency fix
$ git commit -a -m "Fix in a hurry"
$ git switch

Title: Git Stash Documentation
Summary
The git stash command is used to temporarily store changes made to a repository, allowing users to switch between different versions of their code, and includes various options and parameters for customizing its behavior, along with examples of how to use stash in common workflows, such as pulling into a dirty tree and interrupting a workflow to make an emergency fix.