git stash single file code example

Example 1: git stash one file

git stash save -- just_my_file.txt

Example 2: git stash one file

$ git stash -- filename.ext

Example 3: how to apply changes in a single file from stash

git checkout stash@{0} -- <filename>

Example 4: git stash apply specific file

git diff stash^! -- path/to/relevant/file/in/stash.ext perhaps/another/file.ext > my.patch
git apply < my.patch

Example 5: stash a single file

git stash push -m "describe changes to filename.ext" filename.ext

Example 6: aad a single file to stash

git stash push -m welcome_cart app/views/cart/welcome.thtml