git 推送而不设置上游
git push without setting upstream
如果通过以下方式从主分支创建分支:
git checkout -b general
然后我可以通过以下方式推送分支将军:
git push
如果运行
git branch -vv
我可以看到 general
没有跟踪任何远程分支。那么,如何在不设置任何上游的情况下进行推送?
So, how can I push without having set any upstream?
git push
命令仅要求您在使用时设置上游:
- a
push.default
设置为
simple
或
upstream
请注意,有五种可能的设置(请参阅 the git config
documentation):none
、current
、matching
、simple
和 upstream
.虽然 none
会失败,但不会失败 因为缺少上游: 它会失败,因为它总是失败。 current
和 matching
设置不使用当前分支的上游,实际上 matching
甚至不需要 be当前分支。
此处的 第一个 项目符号点(缩进较少)是为了表明您必须执行 git push
,它使用 push.default
中的设置第一名。注意:
git 推送 <em> 远程 refspec</em>
甚至没有到达第一个要点,因为您向 git push
提供了一个 refspec 参数。 (参见 the git push
documentation。)
因此,这为您提供了问题的答案:要么在 git push
期间指定一个 refspec,要么将 push.default
设置为某个值,这样您缺少 refspec 就会调用 push.default
你设置的不需要上游。
如果你想设置你的分支来跟踪远程分支,你可以使用
git checkout -b <branch> <remote>/<branch>
下面将创建您的分支的本地副本,但不会设置它应该跟踪到的远程分支。
git checkout -b general
如果通过以下方式从主分支创建分支:
git checkout -b general
然后我可以通过以下方式推送分支将军:
git push
如果运行
git branch -vv
我可以看到 general
没有跟踪任何远程分支。那么,如何在不设置任何上游的情况下进行推送?
So, how can I push without having set any upstream?
git push
命令仅要求您在使用时设置上游:
- a
push.default
设置为simple
或upstream
请注意,有五种可能的设置(请参阅 the git config
documentation):none
、current
、matching
、simple
和 upstream
.虽然 none
会失败,但不会失败 因为缺少上游: 它会失败,因为它总是失败。 current
和 matching
设置不使用当前分支的上游,实际上 matching
甚至不需要 be当前分支。
此处的 第一个 项目符号点(缩进较少)是为了表明您必须执行 git push
,它使用 push.default
中的设置第一名。注意:
git 推送 <em> 远程 refspec</em>
甚至没有到达第一个要点,因为您向 git push
提供了一个 refspec 参数。 (参见 the git push
documentation。)
因此,这为您提供了问题的答案:要么在 git push
期间指定一个 refspec,要么将 push.default
设置为某个值,这样您缺少 refspec 就会调用 push.default
你设置的不需要上游。
如果你想设置你的分支来跟踪远程分支,你可以使用
git checkout -b <branch> <remote>/<branch>
下面将创建您的分支的本地副本,但不会设置它应该跟踪到的远程分支。
git checkout -b general