git的-X“他们的”不处理新的/删除的文件冲突? [英] Does git's -X "theirs" not handle new/deleted file conflicts?

查看:552
本文介绍了git的-X“他们的”不处理新的/删除的文件冲突?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题,我是执行一个 git rebase -s递归-X他们等... 并且惊讶地被以下类型的冲突停止:




  • 由他们删除

  • 由他们删除

  • 由我们删除



是否有某些原因导致策略无法应付这些?

(我不知道如果这很重要,但git不会在输出中报告冲突,那么它只是说当你解决了这个问题时,运行git rebase --continue

更新下面是一个脚本,它不能完全复制,但几乎:

  git init 
git symbolic-ref HEAD refs / heads / Branch1#只需获得'right'分支名称
echo在A中添加> DeletedByThem.txt
git add -A
git commit -m A

echo在B>中修改> DeletedByThem.txt
git add -A
git commit -m B

echo在C>>中修改> DeletedByThem.txt
echo在C>中添加DeletedByUs.txt
git add -A
git commit -m C

git checkout -b Branch2
echo在D中修改>> DeletedByUs.txt
git rm DeletedByThem.txt
git add -A
git commit -m D

echo在E>中修改> DeletedByUs.txt
git add -A
git commit -m E

在这一点,你应该有这样的:

  Branch1:A  -  B  -  C 
\
Branch2 :D - E

我们想要的是:

  Branch1:A  -  B  -  C 
\
分支2:D - E


所以:

  git rebase -s递归-X他们的 - 到[SHA of B] Branch1 Branch2 

这会再现'被他们删除'和'被我们删除'问题,但不会重现'由他们添加',也不存在任何冲突报告。



从我可以收集的情况来看,在这种情况下'被他们删除'意味着在B之后被修改,然后被删除(所以我们想要在Branch2中删除它),并且由我们删除意味着在B之后创建(因此我们想将它保留在Branch2中)。

从什么我可以从我的真实(和巨大)回购的历史中看出,'由他们添加'与错误检测到的重命名相关(即完全不同文件夹中的相同文件被标识为重命名)。

b $ b

解决方案

产生冲突的原因是因为rebase正试图应用无法应用的补丁。



补丁指示我们删除的文件,它找不到。

这种行为是有目的的。

Following on the scenario from this question, I'm performing a git rebase -s recursive -X theirs etc... and am surprised to be stopped with the following types of conflicts:

  • added by them
  • deleted by them
  • deleted by us

Is there some reason the strategy doesn't cope with these?

(I don't know if this is significant, but git doesn't report conflicts in the output, it just says When you have resolved this problem run "git rebase --continue")

UPDATE Here's a script that doesn't quite reproduce, but nearly:

git init
git symbolic-ref HEAD refs/heads/Branch1  #just to get the 'right' branch name
echo Added in A > DeletedByThem.txt
git add -A
git commit -m A

echo Modified in B >> DeletedByThem.txt
git add -A
git commit -m B

echo Modified in C >> DeletedByThem.txt
echo Added in C > DeletedByUs.txt
git add -A
git commit -m C

git checkout -b Branch2
echo Modified in D >> DeletedByUs.txt
git rm DeletedByThem.txt
git add -A
git commit -m D

echo Modified in E >> DeletedByUs.txt
git add -A
git commit -m E

At this point, you should have this:

Branch1:    A - B - C
                     \
Branch2:              D - E

What we want is this:

Branch1:    A - B - C
                 \
Branch2:          D - E

So:

git rebase -s recursive -X theirs --onto [SHA of B] Branch1 Branch2

This reproduces the 'deleted by them' and 'deleted by us' problems, but doesn't reproduce the 'added by them', nor the absence of any conflict report.

From what I can gather, in this context 'deleted by them' thus means "modified after B, then deleted" (so we do want to delete it in Branch2), and "deleted by us" means "created after B" (so we want to keep it in Branch2)

From what I can tell from the history of my real (and enormous) repo, the 'added by them' is related to incorrectly detected renames (i.e. identical files in completely different folders being identified as renames).

解决方案

The reason that you get a conflict is because rebase is trying to apply a patch that is impossible to apply.

The file that the patch instructs us to delete, it can't find.

This behavior is by design.

这篇关于git的-X“他们的”不处理新的/删除的文件冲突?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆