git push -u是什么意思?
我有两个不同版本的git。
在1.6.2版本中, git push
没有 -u
选项。它只出现在1.7.x版本中。
I have two different versions of git.
In the 1.6.2 version, git push
does not have the -u
option. It only appears in the 1.7.x version.
从文档中, -u
与变量有关
branch.<name>.merge
位于 git config
中。这个变量描述如下:
in git config
. This variable is described below:
Defines, together with branch.<name>.remote, the upstream branch
for the given branch. It tells git fetch/git pull which branch to merge.
什么是上游分支?
What is an upstream branch ?
上游指的是其他人将从其中撤回的主要回购,例如你的GitHub回购。 -u选项自动为您设置上游,将您的repo链接到*服务器。这样,未来,Git会知道你想推到哪里以及你想从哪里拉取,所以你可以使用 git pull
或 git push
不带参数。一点点,这篇文章解释并演示了这个概念。
"Upstream" would refer to the main repo that other people will be pulling from, e.g. your GitHub repo. The -u option automatically sets that upstream for you, linking your repo to a central one. That way, in the future, Git "knows" where you want to push to and where you want to pull from, so you can use git pull
or git push
without arguments. A little bit down, this article explains and demonstrates this concept.