【问题标题】:Merge conflict while trying to merge stashed code尝试合并隐藏代码时合并冲突
【发布时间】:2016-09-24 12:50:19
【问题描述】:

所以我为我的 Swift 项目隐藏了我的更改,以便我可以提出拉取请求,然后将我所做的更改与新的拉取合并。但是,每当我尝试合并我的更改时,我都会遇到关于 UserInterfaceState.xcuserstate XCode 文件的合并冲突。我没有尝试让我合并我隐藏的代码,而且我担心我会丢失一个下午的代码。

我尝试将 *.xcuserstate 添加到 .gitignore,但这似乎没有任何作用。然后我尝试删除该文件,该文件与存储中的版本产生了修改/删除冲突。这是我尝试获取隐藏代码时遇到的错误:

$ git stash apply
CONFLICT (modify/delete): myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate deleted in Updated upstream and modified in Stashed changes. Version Stashed changes of myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate left in tree.

尝试 Flows 推荐的这是我收到的输出:

$ git reset --hard
HEAD is now at e509ffa Fixed bugs
$ git stash pop
myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate: needs merge
unable to refresh index

$ git rm myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate
myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate: needs merge
rm 'myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate'
$ git stash pop
CONFLICT (modify/delete): myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate deleted in Updated upstream and modified in Stashed changes. Version Stashed changes of myProj.xcodeproj/myProj.xcworkspace/xcuserdata/lnd.xcuserdatad/UserInterfaceState.xcuserstate left in tree.

有什么办法可以解决这个问题吗?似乎没有任何工作,所以任何帮助将不胜感激,谢谢。

【问题讨论】:

  • 是否需要更改相关文件?还是应该像在上游一样将其删除?如果不需要,在应用您的存储并查看冲突后,从文件系统中删除该文件,运行:git rm <filename> 并提交更改。
  • 你有未合并的文件吗?请参阅此链接:unable to refresh index。使用git status 确保您的工作树是干净的。如果没有,请在再次执行 stash pop 之前解决并提交冲突
  • @Andonaeus 我试图删除该文件,但最终导致修改/删除冲突。我在原始帖子中发布了回复。
  • @shadowarcher 您应该在应用存储后删除该文件。
  • @shadowarcher :您是否尝试在上次编辑后解决冲突并提交?

标签: xcode git github merge


【解决方案1】:

你可以试试这个

使用--hard 选项将主服务器重置为origin/master

使用 stash pop 应用存储

Git 应该告诉你有冲突。编辑UserInterfaceState.xcuserstate 文件以查看冲突并纠正它。

git commit

如果它不起作用,您可以粘贴命令的所有 git 输出吗?

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-18
    • 1970-01-01
    • 1970-01-01
    • 2020-02-28
    • 2011-08-20
    • 2017-03-04
    • 2011-03-13
    • 2017-07-24
    相关资源
    最近更新 更多