我的 git 存储库有 2 个分支:master 和development。我想要一个能够自动合并从开发到主控的所有更改的脚本。
我使用 Jenkins:Git 插件克隆存储库,然后运行此脚本(“版本”变量是作业参数):
# merge
git checkout -b develop origin/develop
git checkout master
git merge -Xtheirs --squash develop -m "v${version}"
# commit
git commit -m "v${version}"
# tag
git tag v${version} -m "v${version}"
# push
git push origin v${version}
我在测试存储库上尝试过它,但失败了:
git merge -Xtheirs 开发
冲突(删除/修改):在develop中删除test.txt并在HEAD中修改。 test.txt 的版本 HEAD 留在树中。
自动合并失败;修复冲突,然后提交结果。
我该如何解决这个冲突自动地?我希望脚本始终根据“开发”分支添加/修改/删除文件,因为无论如何都不会触及 master ......
The -X theirs
合并策略仅适用于解决文件中存在冲突的块。这些选项的文档位于the git-merge手册页:
ours
This option forces conflicting hunks to be auto-resolved
cleanly by favoring our version. Changes from the other tree
that do not conflict with our side are reflected to the merge
result.
This should not be confused with the ours merge strategy, which
does not even look at what the other tree contains at all. It
discards everything the other tree did, declaring our history
contains all that happened in it.
theirs
This is opposite of ours.
在这种情况下,一个分支删除了该文件,而另一个分支修改了该文件,这与进行不同修改的两个分支之间的简单冲突块是不同的情况。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)