Stash changes while keeping the changes in the working directory in Git

Michael Dorst picture Michael Dorst · Jul 24, 2013 · Viewed 38.4k times · Source

Is there a git stash command that stashes your changes, but keeps them in the working directory too? So basically a git stash; git stash apply in one step?

Answer

user456814 picture user456814 · Jul 25, 2013

For what it's worth, another way to do this is to stage the changes you want to keep, and then stash everything using --keep-index:

$ git add modified-file.txt
$ git stash push --keep-index

The commands above will stash everything, but it will leave the files staged in your working directory.

From the official Linux Kernel Git documentation for git stash or from git-scm:

If the --keep-index option is used, all changes already added to the index are left intact.