3
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国家会丢失?

4

1 回答 1

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).
于 2012-12-17T17:23:15.563 回答