git rerere不会自动提交自动提交的合并解决方案

时间:2013-08-01 20:29:17

标签: git git-rerere

我正在尝试使用共享的rerere缓存来自动执行一次性集成/测试分支。

我们的想法是,当推送分支时,rerere缓存应该是最新的,以便这些合并始终通过。但是,他们没有:

>>> git merge --no-ff invoicing
Staged 'analysisrequest.py' using previous resolution.
Staged '__init__.py' using previous resolution.
Auto-merging __init__.py
CONFLICT (content): Merge conflict in __init__.py
Auto-merging analysisrequest.py
CONFLICT (content): Merge conflict in analysisrequest.py
Automatic merge failed; fix conflicts and then commit the result.

此时,rerere已经上演了它所记住的决议,并且不存在实际的冲突。我可以运行git commit,然后继续,但我的integration-test-build脚本会看到错误。我已经尝试将--rerere-autoupdate添加到git merge命令中,但没有任何变化。我已将repo配置为启用并自动应用rerere匹配。

如果git merge能够使用我以前的分辨率并且如果它们足够的话可以继续而不会失败?

1 个答案:

答案 0 :(得分:10)

即使使用--rerere-autoupdate标记,git merge似乎也不愿意在没有人工输入的情况下自动完成合并。在这种情况下,它会以错误状态执行,并且您的集成工具拒绝继续。

我不知道您的自动合并是如何发生的,即,您是否可以更改执行的git命令。如果可以,则可以执行以下命令。

git merge --no-ff branch-to-merge --rerere-autoupdate
if [[ $(git rerere diff) ]]
then
    git commit --no-edit
else
    $(exit 1)
fi
  • git rerere diff列出需要在rerere
  • 之后解析的文件
  • --no-edit是必要的,以防止打开提交消息编辑器
  • 如果rerere无法干净地合并所有更改,则此语句仍将以错误状态执行,并且不会提交合并。
    • 提交消息仍将包含冲突文件
  • exit 1需要在$()内,除非您想退出shell(猜猜我是怎么知道的: - ))
相关问题