没有做任何更改时Git合并冲突

时间:2014-09-17 21:47:56

标签: git git-merge

我克隆了一个回购,然后,几个小时后,我做了一个“git pull”'。然而,合并冲突出现了,我不明白为什么,因为我没有对克隆回购进行任何改变。

git status
On branch master
Your branch is up-to-date with 'origin/master'.

nothing to commit, working directory clean


git pull
remote: Counting objects: 6211, done.
remote: Compressing objects: 100% (849/849), done.
remote: Total 3237 (delta 2756), reused 2846 (delta 2371)
Receiving objects: 100% (3237/3237), 865.51 KiB | 152.00 KiB/s, done.
Resolving deltas: 100% (2756/2756), completed with 867 local objects.
From git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next
 + 76c2c6d...4d046e9 master     -> origin/master  (forced update)
 + 1e13928...003e6ba akpm       -> origin/akpm  (forced update)
 + 9d1d11d...8bcfe39 akpm-base  -> origin/akpm-base  (forced update)
   37504a3b..8ba4caf stable     -> origin/stable
 * [new tag]         next-20140918 -> next-20140918
Performing inexact rename detection: 100% (318500/318500), done.
Auto-merging tools/testing/selftests/rcutorture/doc/TREE_RCU-kconfig.txt
CONFLICT (content): Merge conflict in tools/testing/selftests/rcutorture/doc/TREE_RCU-kconfig.txt
Auto-merging tools/testing/selftests/rcutorture/configs/rcu/TREE03
Auto-merging localversion-next
CONFLICT (add/add): Merge conflict in localversion-next
Auto-merging kernel/rcu/tree.c
CONFLICT (content): Merge conflict in kernel/rcu/tree.c
Auto-merging drivers/target/target_core_fabric_configfs.c
CONFLICT (content): Merge conflict in drivers/target/target_core_fabric_configfs.c
Auto-merging drivers/target/iscsi/iscsi_target_util.c
Auto-merging drivers/hwmon/Kconfig
Auto-merging drivers/gpu/drm/i915/intel_ringbuffer.c
Auto-merging drivers/gpu/drm/i915/intel_drv.h
Auto-merging drivers/gpu/drm/i915/intel_dp.c
Auto-merging drivers/gpu/drm/i915/intel_display.c
Auto-merging drivers/gpu/drm/i915/i915_gem.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/i915/i915_gem.c
Auto-merging drivers/clk/rockchip/clk-rk3288.c
Auto-merging arch/mips/include/asm/topology.h
Auto-merging arch/m68k/coldfire/m54xx.c
Auto-merging Next/quilt-import.log
CONFLICT (add/add): Merge conflict in Next/quilt-import.log
Auto-merging Next/merge.log
CONFLICT (add/add): Merge conflict in Next/merge.log
Auto-merging Next/SHA1s
CONFLICT (add/add): Merge conflict in Next/SHA1s
warning: inexact rename detection was skipped due to too many files.
warning: you may want to set your merge.renamelimit variable to at least 5040 and retry the command.
Automatic merge failed; fix conflicts and then commit the result.

git status
On branch master
Your branch and 'origin/master' have diverged,
and have 236 and 347 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)

You have unmerged paths.
  (fix conflicts and run "git commit")

Changes to be committed:
    ...

Unmerged paths:
  (use "git add <file>..." to mark resolution)

    both added:      Next/SHA1s
    both added:      Next/merge.log
    both added:      Next/quilt-import.log
    both modified:   drivers/gpu/drm/i915/i915_gem.c
    both modified:   drivers/target/target_core_fabric_configfs.c
    both modified:   kernel/rcu/tree.c
    both added:      localversion-next
    both modified:   tools/testing/selftests/rcutorture/doc/TREE_RCU-kconfig.txt

3 个答案:

答案 0 :(得分:7)

首先,我每天都要使用一些预防措施......

当我不期待任何实际合并时,我学会了使用git merge --ff-only。我发现它也可以使用git pull --ff-only,但更多时候我使用git pull --rebase因此它不会创建任何合并提交,而是重播我的本地更改(如果有的话)上游。不过,我无法帮助解释,因为我不知道linux-next的规则。

发生合并冲突的唯一原因是合并到不同的分支。如果你的分支没有改变,人们会期待一个干净的快进合并。适合您的描述的唯一解释是远程不再在其历史记录中包含您的提交,这意味着上游具有重写的历史记录。这在某些工作流程中非常常见,其中已发布的分支只是指向最新提交更多更改集的指针。但是,我没有 linux-next 的具体信息。

危险区域:出现这种情况时,您可以使用git fetch获取上游数据,然后使用git reset --hard origin/master更新您的分支参考(替换 origin master 具有实际的远程和分支名称)。但是请确保您没有要保存的任何更改,因为这是一种破坏性操作。

答案 1 :(得分:2)

除了Pavel的评论之外,请确保您还没有进行过上游的承诺更改。在这种情况下,如果你看到你有0个需要提交的文件(也许是睡眠不足),那么当你想要开始合并时,你可能会有些困惑。

答案 2 :(得分:0)

我要解决此问题的方法是暂时切换到另一个分支,删除(本地)合并冲突的分支,然后再次获取该分支。