我正在尝试重新绑定一个分支并且git正在推出,因为它试图执行一些失败的合并操作。我怎么得到git来阻止这个?
# git rebase -f --onto master~2 master~ master
First, rewinding head to replay your work on top of it...
Applying: r1002 - CS 1.0.23
Using index info to reconstruct a base tree...
M about.html
<stdin>:68: trailing whitespace.
<stdin>:115: trailing whitespace.
<stdin>:201: trailing whitespace.
<stdin>:2369: trailing whitespace.
<stdin>:2385: trailing whitespace.
warning: squelched 2305 whitespace errors
warning: 2310 lines add whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging about.html
CONFLICT (content): Merge conflict in about.html
Failed to merge in the changes.
Patch failed at 0001 r1002 - 1002
The copy of the patch that failed is found in:
/local/melder/tmp/test/.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".
正如您所看到的,有2000多个空格错误,而不是手动合并的东西。
编辑:现在不进行合并,现在支持这一步:
# git add -A
# git rebase --continue
击> <击> 撞击>
编辑:没关系,这是一个愚蠢的想法。
答案 0 :(得分:15)
我今天遇到了同样的问题:由于空白错误导致冲突,rebase失败了。
使用whitespace
选项(git rebase --whitespace=fix
和git rebase --whitespace=nowarn
)的不同设置进行失败的试用后,对我有用的解决方案是忽略递归合并策略中的尾随空白错误({{1}如果需要,首先运行任何rebase):
git rebase --abort
取决于空白错误的类型,选项git rebase -Xignore-space-at-eol <newbase>
和-Xignore-space-change
可能更有用。我不知道选项-Xignore-all-space
是否也有效。
答案 1 :(得分:5)
不会支持这个问题。您现在在文件中有冲突标记!
空白问题是警告,你不应该有那么多合法的冲突。如果文件是要解决的噩梦,您可能需要手动重建它。这取决于你正在做什么。
很多时候,这两个基地是如此不同,以至于每次提交你都会让你处理这场可怕的冲突。我倾向于避开rebase工作流程并订阅合并/重置。以下是我的工作:http://dymitruk.com/blog/2012/02/05/branch-per-feature/
如果您的问题只是行结尾等空白问题,您可以先尝试通过在每一侧执行过滤器分支或交互式rebase来清理您的存储库,以使每次提交的空白保持一致。
此外,我使用超越比较3或Perforce Merge来进行冲突解决。 BC3具有语法感知能力,应该最好地处理空白。很多时候,它甚至都不会打开,因为它会为你解决冲突,你可以继续。
答案 2 :(得分:1)
我认为大多数差异查看器(特别是带有GUI的浏览器)允许您选择如何处理空白更改。
我建议您使用meld
之类的内容作为git mergetool
来自动纠正这些冲突。启动meld
后,设置它的空白处理政策(来自Text filters
面板的Preferences
标签),它会自动调整这些更改。
答案 3 :(得分:1)
今天我用这种方式解决了这个问题:
REMOVE_AFTER="3cd7a0db76ff9dca48979e24c39b408c"
REPO="git@github.com:company/repo.git"
cd ~/tmp
git clone $REPO gitfix
cd gitfix
git checkout --orphan temp $REMOVE_AFTER
git commit -m "Truncated history"
git rebase --strategy=recursive --strategy-option=theirs --onto temp $REMOVE_AFTER master
在rebase期间,由于删除文件而导致CONFLICT (modify/delete)
冲突,您可以通过以下方式解决:
git rm path/to/both/deleted/file
git rebase --continue
在rebase期间,当您遇到其他冲突时,您需要手动修复它,之后:
git add path/to/conflict/file
git rebase --continue
完成后,rebase说All done.
然后你可以:
git branch -D temp
现在检查结果:
git log --format=oneline