git stash命令后文件状态丢失

时间:2012-12-17 13:28:07

标签: git git-stash

echo Hello. > a.txt
git add .
echo Bye. >> a.txt
git status -s
>>> AM

我们可以看到状态为AM
但是在做以下事情

git stash
git stash pop
git status -s
>>> A

州是A。 为什么M州失去了?

1 个答案:

答案 0 :(得分:2)

这是预期的行为。要按照您的期望重建它(保存A& M),请使用

git stash pop --index

来自文档:

git-stash(1):

If the --index option is used, then tries to reinstate not only the working
tree’s hanges, but also the index’s ones. However, this can fail, when you have
conflicts (which are stored in the index, where you therefore can no longer apply
the changes as they were originally).