git stash 无法应用保存的更改
我尝试使用以下命令保存 git 状态: git stash save changes_1。 我可以使用以下命令查看存储列表: git stash list
但是当我尝试使用以下命令应用存储时: git stash apply stash@{0}。 现在,我看不到 git diff 正在更新任何更改。并且显示消息“已经更新!”
因此,简而言之 git stash 无法应用保存的更改。 任何帮助。
I tried saving a git state using : git stash save changes_1.
I can see the stash list using: git stash list
But when I try to apply the stash using: git stash apply stash@{0}.
Now, I cannot see any changes are getting updated with git diff. and it is showing the message "Already uptodate!"
So, in short git stash is not able to apply the changes saved.
Any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
当先前应用了存储或应用它不执行任何操作(例如当前分支已经具有这些更改)时,就会发生这种情况。考虑以下场景:
现在我们手动重新添加该行并提交它:
这里 git stash apply 不执行任何操作。
This happens when a stash was applied previously or applying it does nothing e.g. current branch already has those changes. Consider the following scenario:
Now we re-add that line by hand and commit it:
Here
git stash apply
does nothing.尝试 git status -s 看看是否有更改。
如果它们在那里,那么您就已经准备好了,如果没有,请使用 git stash list 并确保您保存的存储位于索引 0 处。如果您尝试应用一个存储,该存储的更改已经是工作分支的一部分,那么它将已经达到日期。
如果您愿意,可以将当前分支重置为最后一次提交。 Git reset --hard HEAD 然后尝试再次应用该存储。请小心,因为所有当前未隐藏的更改和未推送的提交都将丢失。
Try git status -s to see if the changes are there.
If they are there you are all set, if not use git stash list and make sure your saved stash is at index 0. If you try to apply a stash that has changes that are already part of the working branch it will be already up to date.
If you wanted you could reset your current branch to the last commit. Git reset --hard HEAD and then try to apply that stash again. Care as all current changes not stashed and commits not pushed will be lost.