在分支和隐藏后丢失了我在git中的更改?

在分支和隐藏后丢失了我在git中的更改?,git,Git,我想我做了一些不该做的事。我试图使用隐藏,但认为我应该分支,并在那里做。总之,以下是我执行的命令: git branch test # created my test branch git checkout test # moved to my test branch git status # showed that the files were still changed. git stash # testing stash git stash

我想我做了一些不该做的事。我试图使用隐藏,但认为我应该分支,并在那里做。总之,以下是我执行的命令:

git branch test     # created my test branch
git checkout test   # moved to my test branch
git status          # showed that the files were still changed.
git stash           # testing stash
git stash list      # showed that the stash was there
git status          # showed that the files were still changed?
git diff            # showed that the differences were only file permissions.
git stash apply     # Tried to get back my changes. States:
                    #   error: Your local changes to the following files would be overwritten by merge:
                    #   ...
                    #   Please, commit your changes or stash them before you can merge.
                    #   Aborting
git commit file -m "- committing test code that doesn't work."
git status          # Shows that it's clean
所以,我认为问题在于分支和签出删除了我的更改,而不是保留它们。对吗?如果没有,我可以取回我的更改吗

git stash apply     # Tried to get back my changes. States:
                    #   error: Your local changes to the following files would be overwritten by merge:
                    #   ...
                    #   Please, commit your changes or stash them before you can merge.
                    #   Aborting
git commit file -m "- committing test code that doesn't work."
git status          # Shows that it's clean
这表明未应用隐藏(尝试被中止,因为您有可能被隐藏覆盖的本地更改)

最后两个命令提交了工作目录中存在的更改(至少,我假设它们提交了-您已经从运行的命令列表中删除了
git add
步骤)。您永远不会重新应用隐藏,因此它应该仍然存在

检查
git存储列表中的内容


从注释中,
git stash list
表示
stash@{0}:WIP on test:0581365已添加
。这意味着您有一个隐藏的提交(例如
git stash apply

git stash list
说明了什么?它说:
stash{0}:WIP on test:0581365 Added
@Adrian查看我的修订答案。仅供参考,该文件已经添加到这组命令之前。是的,这就是我开始执行此操作的页面。哦,在所有这些之前,这个文件已经被添加到了存储库中。问题是它没有被应用,所以我要应用它吗?如果我放松了这些改变,哦,好吧,但我想知道,当我有更重要的事情发生时,发生了什么事来阻止它在未来发生。@Adrian怎么说?如果您期望的更改显示在隐藏差异中,但它仍然不适用,那么使用错误或隐藏不适用的原因来修改问题将很有帮助。您还可以执行
git签出
并以这种方式检查文件。