How to stash a single file or directory in Git

By Patricia Sauer ·

Assorted-color thread lot

Stashing means saving your local changes away. Your working directory will be reverted to match the HEAD commit. It might be that you want to stash the changes of your whole working directory (aka everything) or that you want to stash a directory.

How to stash your whole working directory

In Git you can stash the changes of your whole working directory by using the Git stash command:

git stash

How to stash a directory or file

In case that you want to stash the changes of a specific directory or file, you can use the following Git stash command:

git stash push -- path/to/folder/or/file

Reference

For full reference see Git stash documentation.

More about Git

All articles →