Git设置默认的push分支

Git设置默认的push分支

 

Git缺省情况下并没有什么默认的推送的分支,如果你执行

$> git push

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

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)

Everything up-to-date

就会告诉你给一个警告!

所以如果你即使要推送当前对应分支,你还是要告诉git,例如当前是myBranch,要推送的话,

$> git push origin myBranch

为了简化这个命令,也就是当我们输入

$> git push

让git直接推送到本branch就好

要做到这一点,就需要告诉默认的推送目的branch,这个需要是动态的,不然当我们checkout到别的branch,就会有问题。git为我们提供了这个功能,就是直接设置默认的推送branch为current

$> git config –global push.default current

再用下面的命令查看我们设置的值

$> git config –global push.default

current

看到了了吧,输出我们刚才设置的值, current

接下来,直接执行

$> git push

看看效果吧

 

版权所有,禁止转载. 如需转载,请先征得博主的同意,并且表明文章出处,否则 按侵权处理.

    分享到:
This entry was posted in Git. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*