本文介绍了如何让Git默认使用所有存储库的rebase?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法设置主机Git存储库,以便从其本地克隆完成的 code>默认?通过在StackOverflow上搜索,我了解到了 branch.autosetuprebase ,但它需要单独为每个克隆配置。



我的项目流设置为使得我们 pull develop merge 将一个功能分支添加到它。这 pull 几乎总是使用 --rebase ,所以我想弄清楚这是否可以成为默认值。

编辑)根据以下讨论重新构建问题,并使用 从最细粒度到最一般,它们是:

1。 分支。< branchname> .rebase



设置为 true 意味着除非明确使用 git pull --merge ,否则该特定分支将始终通过重新绑定从其上游拉取。



2。 branch.autosetuprebase



设置为始终意味着每当创建一个跟踪分支时,就会为其创建一个类似上面的配置条目。对于更细粒度的控制,这也可以设置为从不,本地或远程并且可以在每个存储库或全局设置。请参阅 git config --help 了解更多详情。



3。 pull.rebase



设置为 true 表示 git pull 总是等于 git pull --rebase (除非分支。< branchname> ; .rebase 显式设置为 false )。这也可以设置每个存储库或全球。



结论



因此,虽然您不能更改默认对未来所有存储库克隆的行为,可以通过 git config --global pull.rebase true 更改所有当前用户(现有和未来)存储库的默认值。

Is there a way to setup the host Git repository such that any git pull done from its (local) clones uses --rebase by default? By searching on StackOverflow, I learned about branch.autosetuprebase, but it needs to be configured per clone individually.

My project flow is set up such that we pull the develop branch before mergeing a feature branch to it.This pull nearly always uses --rebase, so I am trying to figure out if this can be the default.

(Edit Restructured the question according to discussion below with Jonas Wielicki.)

解决方案

There are now 3 different levels of configuration for default pull behaviour. From most fine grained to most general, they are:

1. branch.<branchname>.rebase

Setting this to true means that that particular branch will always pull from its upstream via rebasing, unless git pull --merge is used explicitly.

2. branch.autosetuprebase

Setting this to always means that whenever a tracking branch is created, a configuration entry like the one above will be created for it. For finer grained control, this can also be set to never, local or remote and can be set per repository or globally. See git config --help for further details.

3. pull.rebase

Setting this to true means that git pull is always equivalent to git pull --rebase (unless branch.<branchname>.rebase is explicitly set to false). This can also be set per repository or globally.

Conclusion

So while you can't change the default behaviour for all future clones of a repository, you can change the default for all of the current user's (existing and future) repositories via git config --global pull.rebase true.

这篇关于如何让Git默认使用所有存储库的rebase?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-25 03:19