git push -u是什么意思?

我有两个不一样版本的git。 在1.6.2版本中, git push没有-u选项。 它只出如今1.7.x版本中。 git

从文档中, -u与变量相关 fetch

branch.<name>.merge

git config 。 该变量以下所述: this

Defines, together with branch.<name>.remote, the upstream branch 
for the given branch. It tells git fetch/git pull which branch to merge.

什么是上游分支? spa


#1楼

这已再也不是最新的! code

Push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, 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.

Since Git 2.0, Git defaults 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.

#2楼

“上游”指的是其余人将从中获取的主要回购,例如您的GitHub回购。 -u选项会自动为您设置上游,将您的仓库连接到中央仓库。 这样,在将来,Git“知道”你想要推送到哪里以及你想从哪里取出,因此你能够使用git pullgit push而不须要参数。 有点下来, 这篇文章解释并演示了这个概念。 ci

相关文章
相关标签/搜索