我有两个不同版本的git.在1.6.2版本中,git push没有-u选项.它只出现在1.7.x版本中.
从文档中,-u它与变量有关
branch.<name>.merge
Run Code Online (Sandbox Code Playgroud)
在git config.该变量如下所述:
Defines, together with branch.<name>.remote, the upstream branch
for the given branch. It tells git fetch/git pull which branch to merge.
Run Code Online (Sandbox Code Playgroud)
什么是上游分支?
Raf*_*ler 350
"上游"指的是其他人将从中获取的主要回购,例如您的GitHub回购.-u选项会自动为您设置上游,将您的仓库链接到中央仓库.这样,在未来,Git"知道"你想要推送到哪里以及你想要从哪里开始,所以你可以使用git pull或git push不使用参数.有点下来,这篇文章解释并演示了这个概念.
这已不再是最新的!
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.
Run Code Online (Sandbox Code Playgroud)