我想我做了一些我不应该做的事情。我试图使用藏匿处,但认为我应该分支,并在那里做。无论如何,这些是我做的命令:
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
所以,我认为问题在于分支和检查擦除了我的更改而不是保留它们。那是对的吗?如果没有,我可以收回我的更改吗?
答案 0 :(得分:0)
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 stash list
说的内容。
在评论中,git stash list
说stash@{0}: WIP on test: 0581365 Added
。这意味着你有一个stashed提交,you can apply(例如git stash apply
)。