解决git中的冲突

时间:2018-07-16 13:18:16

标签: git

我拥有自己的存储库,其结构如下所示

enter image description here

您可以看到在某些时候存在分歧。 master分支具有一个构建Visual Studio解决方案的CMake文件,并且缺少在FibonacciHeap-Implementation分支中已实现的几个文件,但是在实施CMake文件之前,该项目以Visual Studio项目的形式开始(没有当时的CMake文件,文件夹结构也有所不同)。后来我在FibonacciHeap-Branch中的两个来源中进行了一些更改,现在我想将这些更改合并/推送到master中,但是我遇到了冲突。

尝试

我确实从fibonacci堆存储库中尝试了git merge master,但是我删除了我想要保留的文件,所以我做了git reset --hard

如果我这样做:

git pull origin master --rebase我收到错误:

From https://github.com/lukkio88/CPP-AlgAndDS
 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Applying: Changed struct Node with class Node
Applying: fibonacciHeap implementation draft
Using index info to reconstruct a base tree...
A   BasicAlgorithmsAndDataStructures/AdvancedDataStructures/AdvancedDataStructures.vcxproj
Falling back to patching base and 3-way merge...
CONFLICT (modify/delete): BasicAlgorithmsAndDataStructures/AdvancedDataStructures/AdvancedDataStructures.vcxproj deleted in a3e2c216e74a90fdfbcae805b2caf2a54a7edb4a and modified in fibonacciHeap implementation draft. Version fibonacciHeap implementation draft of BasicAlgorithmsAndDataStructures/AdvancedDataStructures/AdvancedDataStructures.vcxproj left in tree.
error: Failed to merge in the changes.
Patch failed at 0002 fibonacciHeap implementation draft
The copy of the patch that failed is found in: .git/rebase-apply/patch

When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".

我该怎么办?

1 个答案:

答案 0 :(得分:3)

如果要将分支<script> var mySubmitController = Marionette.Object.extend( { initialize: function() { this.listenTo( Backbone.Radio.channel( 'forms' ), 'submit:response', this.actionSubmit ); }, actionSubmit: function( response ) { alert(response.data.form_id); console.log(response); }, }); jQuery( document ).ready( function( $ ) { // Instantiate our custom field's controller, defined above. new mySubmitController(); }); </script> 合并到FibonacciHeap-Implementation中,则应执行相反的操作:

master

如果存在冲突,则可以手动解决(找到# First, checkout master branch > git checkout master # Then merge the branch into it > git merge FibonacciHeap-Implementation >>>>=====部分并保留所需的部分,或者使用外部合并工具。

要使用外部合并工具,您需要先对其进行配置。例如,配置vimdiff:

<<<<<<

然后在发生冲突时从CLI启动该工具:

git config merge.tool vimdiff

有许多工具取决于您的平台和偏好,请查看https://gist.github.com/karenyyng/f19ff75c60f18b4b8149,以进一步了解mergetools。