简体   繁体   English

在git中为特定的远程存储库配置合并选项?

[英]Configure merge options for a particular remote repository in git?

I'd like to use a particular merge option ('ours') for the recursive strategy when pulling from a particular remote repository, but not others. 从特定的远程存储库(而非其他远程存储库)中提取数据时,我想对递归策略使用特定的合并选项(“我们的”)。

I know about git config branch.<name>.mergeoptions "-Xours" , but that's per-branch rather than per-remote repository. 我知道git config branch.<name>.mergeoptions "-Xours" ,但这是每个分支而不是每个远程存储库。

The use case, if it's helpful: I am making a project template that I would like to be able to clone when starting a new project. 用例(如果有帮助的话):我正在制作一个项目模板,希望在启动新项目时能够对其进行克隆。 After working on the project for a while, I'd like to be able to merge in any non-breaking changes from the template with the assumption that conflicts should default to the project and not the template. 在项目上工作了一段时间之后,我希望能够合并模板中的所有不间断更改,并假设冲突应默认为项目而非模板。

Any help in accomplishing this would be great. 任何帮助实现此目标的方法都将非常有用。

There's no "use this on pull " option but if you can retrain your own fingers, it's trivial to do manually. 没有“在pull使用此选项”选项,但是如果您可以重新训练自己的手指,则手动操作很简单。

What git pull does is simply (ok, complicated-ly 1 :-) ) run git fetch followed by git merge . git pull作用很简单(好吧,很复杂1 :-))先运行git fetch然后进行git merge Just do this yourself, or provide yourself an alias or script that does this, and adds -X ours at the merge step. 只需自己执行此操作,或为自己提供一个别名或脚本即可执行此操作,然后在merge步骤中添加-X ours Run that instead of git pull and you're done. 运行它而不是git pull ,就完成了。


1 The complications mostly come from (a) historical baggage, from the days before "remotes" even existed or were used the way they are now, and (b) the fact that you can configure the script to run git fetch followed by git rebase instead. 1复杂性主要来自(a)历史包,,从“远程处理”甚至不存在或以现在的方式使用之前的日子,以及(b)您可以配置脚本以运行git fetch然后进行git rebase的事实代替。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM