# Use git stash

**-a**

**--all**

This option is only valid for `push` and `save` commands.

All ignored and untracked files are also stashed and then cleaned up with `git clean`.

**-u**

**--include-untracked**

**--no-include-untracked**

When used with the `push` and `save` commands, all untracked files are also stashed and then cleaned up with `git clean`.

When used with the `show` command, show the untracked files in the stash entry as part of the diff.

**--only-untracked**

This option is only valid for the `show` command.

Show only the untracked files in the stash entry as part of the diff.

**--index**

This option is only valid for `pop` and `apply` commands.

Tries to reinstate not only the working tree’s changes, but also the index’s ones. However, this can fail, when you have conflicts (which are stored in the index, where you therefore can no longer apply the changes as they were originally).

**-k**

**--keep-index**

**--no-keep-index**

This option is only valid for `push` and `save` commands.

All changes already added to the index are left intact.

**-p**

**--patch**

This option is only valid for `push` and `save` commands.

Interactively select hunks from the diff between HEAD and the working tree to be stashed. The stash entry is constructed such that its index state is the same as the index state of your repository, and its worktree contains only the changes you selected interactively. The selected changes are then rolled back from your worktree. See the “Interactive Mode” section of [git-add\[1\]](https://git-scm.com/docs/git-add) to learn how to operate the `--patch` mode.

The `--patch` option implies `--keep-index`. You can use `--no-keep-index` to override this.

**-S**

**--staged**

This option is only valid for `push` and `save` commands.

Stash only the changes that are currently staged. This is similar to basic `git commit` except the state is committed to the stash instead of current branch.

The `--patch` option has priority over this one.

**--pathspec-from-file=\<file>**

This option is only valid for `push` command.

Pathspec is passed in `<file>` instead of commandline args. If `<file>` is exactly `-` then standard input is used. Pathspec elements are separated by LF or CR/LF. Pathspec elements can be quoted as explained for the configuration variable `core.quotePath.`

**--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.

**\<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}`).

## Reference Links

* <https://git-scm.com/docs/git-stash>
* <https://www.atlassian.com/git/tutorials/saving-changes/git-stash>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://dojo.lkmx.io/ingles/git/use-git-stash.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
