git - 删除在 git stash 中跟踪的文件,然后 git stash pop

标签 git github

我做了 git stash。然后我执行了 git stash pop 但出现了以下错误:

error: Your local changes to the following files would be overwritten by merge: [proj].xcodeproj/project.xcworkspace/xcuserdata/[user].xcuserdatad/UserInterfaceState.xcuserstate Leaflet-[proj]/Leaflet.xcodeproj/xcuserdata/[user].xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist Please commit your changes or stash them before you merge. Aborting

我提交了更改。我再次尝试 git stash pop 无济于事。然后我使用 git rm --cached 删除了文件并提交了这些删除。 git stash pop 现在给出 error: refusing to lose untracked file

git 状态:

Your branch is ahead of 'origin/temp' by 2 commits. (use "git push" to publish your local commits)

Unmerged paths: (use "git reset HEAD ..." to unstage) (use "git add/rm ..." as appropriate to mark resolution)

deleted by us:
[proj].xcodeproj/project.xcworkspace/xcuserdata/[user].xcuserdatad/UserInterfaceState.xcuserstate deleted by us:
[proj]/xcuserdata/[user].xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist

最佳答案

如果您删除了存储中的文件,则无法 merge 存储的更改,因为它无法 merge 到不存在的文件。听起来当你说你早些时候提交了你的更改时你可能已经做了 git add但不是 git commit ?在做了 git commit 之后运行 git stash pop应该工作。如果您确实这样做了但没有这样做,我不确定问题出在哪里,因为您当时没有提供足够的信息。

您现在有几个选择。最安全的可能是做一个 git stash branch <branchname> .这会将你最后的存储 checkout 到一个新的分支上。从那里您可以根据需要对其进行编辑,将您的更改提交到分支,然后将其 merge 回您正在处理的分支。

如果你只是想丢弃你最近的藏品,你可以git stash drop .

如果你想丢弃所有的存储:git stash clear .

关于git - 删除在 git stash 中跟踪的文件,然后 git stash pop,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49930954/

相关文章:

git - 在 git 中更改存储库描述

git - 您的带指纹 (..) 的 key 未经授权(协作)

cPanel 中的 GIT 存储库连接失败

javascript - 如何使用 Visual Studio 将 typescript 网站发布到 GitHub Pages?

javascript - 如何防止 github 在我的 React 代码中突出显示撇号

git - 推送到 git 远程分支

asp.net - 如何 merge 并提交到 TeamCity 中的分支

svn - "git svn fetch"失败,ls-tree 因缺少树对象而死亡

git - Hudson 构建失败时 Git 的预提交 Hook

Heroku 上的 Java 网络应用程序 : Unable to access jarfile