是否可以从git stash中删除单个文件?

noi*_*isy 5 git dvcs git-stash

是否有可能,没有pop整个存储并保存另一个没有这个特定的文件?

iwe*_*ein 2

简短的回答:不,这不是堆栈的工作原理。您可以执行以下操作来获得您想要的结果。

假设您已经存储了一些其他更改,然后对索引(原始更改)进行了更多修改,并且您决定在修改存储时保留这些更改:

#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'
Run Code Online (Sandbox Code Playgroud)

我建议使用此工作流程,而不是尝试直接修改存储。如果你迷失在隐藏的数字中,你也可以使用git stash save 'some other changes'

在某些时候(可能比您想象的更近)跟踪真实的分支会更容易。