如何让Git默认使用所有我的仓库rebase?
有没有办法设置主机Git存储库,以便从其(本地)克隆完成的任何git pull默认使用--rebase ? 通过在StackOverflow上search,我了解了有关branch.autosetuprebase ,但是需要为每个克隆分别进行configuration。 
 我的项目stream程是build立起来的,因此我们在merge一个特性分支之前pull了develop分支。这个pull几乎总是使用--rebase ,所以我想弄清楚这是否可以作为默认值。 
( 编辑根据Jonas Wielicki的讨论重构问题。)
现在有3个不同级别的configuration默认拉动行为。 从最细粒到最一般的他们是:
  1. branch.<branchname>.rebase 
 将其设置为true意味着特定分支将始终通过重新git pull --merge从上游git pull --merge ,除非明确使用git pull --merge 。 
  2. branch.autosetuprebase 
 将其设置为always意味着,无论何时创build一个跟踪分支,都会为其创build一个类似上面的configuration条目。 对于更细粒度的控制,这也可以设置为never , local或remote ,可以设置每个存储库或全局。 有关更多详细信息,请参阅git config --help 。 
  3. pull.rebase 
 设置为true意味着git pull总是等同于git pull --rebase (除非branch.<branchname>.rebase显式设置为false )。 这也可以设置每个存储库或全局。 
结论
 因此,虽然您无法为存储库的所有未来克隆更改默认行为,但可以通过git config --global pull.rebase true更改所有当前用户(现有和未来)存储库的默认行为。 
怎么样
 git config --global --bool pull.rebase true 
这将告诉git总是拉动rebase。
答案是不。
 没有办法build立一个远程仓库,以便克隆它的每个人都有git pull的默认行为改变。 
但是,您可以设置一个服务器端钩子来检查没有人推送合并提交(可能是这样的)。
还有一些您可能感兴趣的configuration选项。所有从远程存储库克隆的开发人员都必须手动设置它们。
  1.选项branch.<name>.rebase 
 您可以configuration一个本地分支,使其始终使用--rebase ,像这样,用分支名称replace<name> : 
 git config branch.<name>.rebase true 
 在master上运行后, .git/config的master节看起来像这样: 
 [branch "master"] remote = origin merge = refs/heads/master rebase = true 
  2.选项branch.autosetuprebase 
为每个Git分支运行前一个configuration命令可能很麻烦,所以你可以configurationGit为每个新的分支自动设置:
 git config branch.autosetuprebase always 
  (您也可以指定never , remote和local ,请参阅man git-config了解详细信息。) 
 如果没有--global选项,configuration将被保存到.git/config ,并且只有当前的存储库受到影响。 使用--global ,configuration被保存到~/.gitconfig ,并且每个未configuration的存储库都会受到影响。 
这个选项不影响已经存在的分支。
  3.选项pull.rebase 
 git config --bool pull.rebase true 
  (你也可以给它--global选项。) 
 如果这个选项是真的,运行git pull就相当于git pull --rebase ,除非branch.<name>.rebase已经设置为false 。 
 这使得--rebase选项在给定分支上发出git pull时是默认选项。 
  @Flimm,我需要添加true才能使你的第一个选项工作。 
所以正确的语法是:
 git config branch.<branch>.rebase true 
 在develop分支上运行这个命令: 
 git config branch.develop.rebase true 
 现在, .git/config的develop部分如下所示: 
 [branch "develop"] remote = origin merge = refs/heads/develop rebase = true