Stash only certain files
If you want to stash only specific files, do the following:
- Stage the files you don't want to stash
-
And the following command:
git stash save --keep-index
For example
# On branch develop
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: fileA
# modified: fileB
#
# Changes not staged for commit:
# (use "git add <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: fileC
# modified: fileD
git stash save --keep-index
This will result on fileA and fileB stashed and fileC and fileD not touched
Related protips:
Written by François Benaiteau
Related protips
1 Response
I think what happens is the exact opposite of what you've described above. Files that are staged remain untouched and the modified (but unstaged) files go into the stash with stash save --keep-index
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Stash
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#