gitgit-stash

How to stash changes while keeping the changes in the working directory? (Git)


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?


Solution

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