git push.default 的设置

  • git,版本控制,
  • 2014-12-16 09:41:40

在新装的 ubuntu 的笔记本上搭建开发环境,新装的软件也都是比较新的,在使用 git 的时候,就出现了一些新情况,以前没有看见的。虽然说是警告,作为一个名程序员,不应该 care warning 的,但是作为一名处女座的程序员,实在是不能容忍这个该死的 warning 总是出现在我提交代码的时候。于是看一下。

warning: push.default is unset; its implicit value is changing in Git 2.0 from 'matching' to 'simple'. To squelch this message and maintain the current behavior after the default changes, use:

git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

git config --global push.default simple

When push.default is set to 'matching', git will push local branches to the remote branches that already exist with the same name. 使用 matching 的话,就可能出现这种情况,你在当前某个分支工作,做一半的时候,来了个紧急的任务,你切换到其他分支去工作了,当你修改完代码后提交代码,这个时候可能会把其他分支的代码一块提交了,这可能不是你想要的。为了谨慎起见,我一直都是使用 simple 的方式提交,哪怕多出一些工作量,也要谨慎。

In Git 2.0, Git will default to the more conservative 'simple' behavior, which only pushes the current branch to the corresponding remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information. (the 'simple' mode was introduced in Git 1.7.11. Use the similar mode 'current' instead of 'simple' if you sometimes use older versions of Git)

其实就是一个问题,push 的时候,提交多少个分支的代码。是当前的分支呢?还是所有本地和服务器名字一样的分支? simple 是 push 当前分支,也就是通过 git pull 命名更新的分支,而 matching 提交的是名字一样的分支,只有服务器存在名字一样的,都提交。

另外,还有个 current 的模式,如果 git 版本比较早的话,可以使用 current 模式。

相关文章

- EOF -

本站文章除注明转载外,均为本站原创或编译。欢迎任何形式的转载,但请务必注明出处,尊重他人劳动。
转载请注明:文章转载自 Binkery 技术博客 [https://binkery.com]
本文标题: git push.default 的设置
本文地址: https://binkery.com/archives/381.html