我有一个分支release-x.x.x
,我想合并到主人。但是,当我执行拉取请求时,它有数百个合并冲突。我认为这是由于我执行的Swift 3迁移。无论哪种方式,我都希望在合并到release-x.x.x
时使用master
中的所有文件版本。我完成了checkout release-x.x.x
和git merge -s recursive -X ours master
。我正在反向执行此操作,以便我可以解决release-x.x.x
上的冲突,然后在master
上创建一个拉取请求并保留所有提交历史记录。
当我运行git status
时,这是一些输出:
added by us: Pods/FirebaseCrash/Frameworks/frameworks/FirebaseCrash.framework/FirebaseCrash
added by us: Pods/FirebaseCrash/Frameworks/frameworks/FirebaseCrash.framework/Headers/FIRCrashLog.h
added by us: Pods/FirebaseCrash/Frameworks/frameworks/FirebaseCrash.framework/Headers/FirebaseCrash.h
added by us: Pods/FirebaseCrash/Frameworks/frameworks/FirebaseCrash.framework/Modules/module.modulemap
deleted by them: Pods/FirebaseCrash/README.md
deleted by them: Pods/FirebaseCrash/batch-upload
deleted by them: Pods/FirebaseCrash/upload-sym
deleted by them: Pods/FirebaseCrash/upload-sym-util.bash
deleted by us: Pods/FirebaseInstanceID/CHANGELOG.md
added by us: Pods/Intercom/Intercom/Intercom.framework/Versions/A/Intercom
both added: MyProject/Base.lproj/Localizable.stringsdict
both deleted: MyProject/Localizable.stringsdict
both added: MyProject/en-HK.lproj/Localizable.stringsdict
我认为我想保留added by us
,both added
并保留任何标记为deleted by them
的内容,因此我已暂存这些文件。我如何处理deleted by us
和both deleted
?如果我尝试git rm Pods/FirebaseInstanceID/CHANGELOG.md
,我会收到错误:Pods/FirebaseInstanceID/CHANGELOG.md: needs merge
。我在这里走的是正确的轨道吗?
答案 0 :(得分:3)
是的,你正走在正确的轨道上。要按照您指定的方式解决合并问题,您应该git rm
标记为deleted by us
或both deleted
的所有文件。
needs merge
错误应该只是一个警告。当我在合并中由一侧删除的文件上运行git rm <file>
时,我得到:
<file>: needs merge
rm '<file>'
后续git status
表示该文件已被删除(并且删除已暂存)。