与 git rebase
,可以使用 -X <strategy-option>
传递 merge 策略选项或 --strategy-option=<strategy-option>
.然而,从手册页中不清楚是否可以传递多个选项(或者后续选项是否替换先前的选项),如果可以,正确的语法是否为 -X <opt1,opt2>
或 -X <opt1> -X <opt2>
.正在运行 git rebase --verbose -m -X <opt1> -X <opt2> <upstream>
不会产生错误,但即使启用了详细输出,也没有迹象表明是应用了两个选项还是只应用了最后一个。
最佳答案
opt1,opt2,opt3
逗号分隔语法用于 git diff
D:\git\git\t>grep -E "\-X" *.sh|grep "\,"
t4047-diff-dirstat.sh: test_must_fail git show -X=20,cumulative
t4047-diff-dirstat.sh:test_expect_success 'explicit defaults: -Xchanges,noncumulative,3' '
t4047-diff-dirstat.sh: git diff -Xchanges,noncumulative,3 HEAD^..HEAD >actual_diff_dirstat &&
不适用于 merge/ rebase 中的策略选项。
对于那些,需要多个 -Xopt1 -Xopt2
。
但我只能找到一个测试这种语法的实例,并且对于失败的情况:t3418-rebase-continue.sh
test_must_fail git rebase -i -s funny -Xopt -Xfoo master topic
所以在实践中,我不确定这是否会被使用。
initial commit (Nov 2009, Git v1.7.0-rc0)其中引入了-X
,一次只用一个策略选项进行测试。
不过我看到一个例子,使用 git cherry-pick:
D:\git\git\t>grep -E "-X.*?-X"*.sh
t3418-rebase-continue.sh: test_must_fail git rebase -i -s funny -Xopt -Xfoo master 主题 t3510-cherry-pick-sequence.sh: test_expect_code 128 git cherry-pick -s -m $mainline --strategy=recursive -X patience -X 我们的初始..anotherpick &&
参见 t3510-cherry-pick-sequence.sh
,这uses the same strategy/options as git merge .
test_expect_code 128 git cherry-pick -s -m $mainline --strategy=recursive -X patience -X ours initial..anotherpick
关于git rebase : passing multiple strategy options,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56800291/