Is it possible, without pop whole stash and save another without this particular file?
Short answer: no, that's not how the stack works. You can do the following though to get the result you're looking for.
Assuming that you have stashed some other changes, then made some more modifications to your index (original changes) and you decide that you want to keep these changes while modifying the stash:
#verify the state you are in
git stash list
git status
git stash #push work in progress on the stash
git stash list #check which stash you need
git stash show stash@{1} #check the changes in the stash
git stash pop stash@{1} #you're now ready to change your 'other' changeset
# hack hack
git stash #modified 'other' change set pushed on the stash
git stash pop stash@{1} #your 'original changes'
I'd recommend this workflow over trying to modify the stash directly. If you get lost in stash numbers you can also use git stash save 'some other changes'
At some point (probably nearer than you think) it's easier to keep track of real branches.
You could try, after popping your stack, to mark the file you don't want to stash as "unchanged":
git update-index --assume-unchanged -- /path/to/file
, and then try to stash, checking if said file is included or not.
git update-index
man page:
--assume-unchanged
--no-assume-unchanged
When these flags are specified, the object names recorded for the paths are not updated.
Instead, these options set and unset the "assume unchanged" bit for the paths.When the "assume unchanged" bit is on, git stops checking the working tree files for possible modifications, so you need to manually unset the bit to tell git when you change the working tree file.
This is sometimes helpful when working with a big project on a filesystem that has very slowlstat(2)
system call (e.g.cifs
).This option can be also used as a coarse file-level mechanism to ignore uncommitted changes in tracked files (akin to what
.gitignore
does for untracked files)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With