我按照vogella GIT教程中的第17节练习“使用(本地)远程存储库”进行操作。执行第17.3步时,我遇到了以下错误:
The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream ../remote-repository.git master
执行的步骤是:
$repo01>git clone --bare . ../remote-repository.git
Cloning into bare repository '../remote-repository.git'...
done.
$mkdir repo02
$\repo02>git clone ../remote-repository.git .
Cloning into '.'...
done.
$\repo01>git status
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: test01
modified: test02.txt
no changes added to commit (use "git add" and/or "git commit -a")
$repo01>git commit -a -m "Some changes"
$\repo01>git push ../remote-repository.git
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream ../remote-repository.git master
什么可能是原因?
push.default
配置,你的上游分支显然没有自动设置。 - kowsky$ git config --global push.default
进行检查。 - kowskypush.default
的simple
设置要像current
设置一样工作,仍然必须配置上游。更准确地说,必须配置branch.<branch>.remote
。如果您还在学习Git,我不建议更改push.default
;只需使用--set-upstream
选项,它可以缩写为-u
,或者使用git push <repository> <branch>:<branch>
,即将分支名称写两次,并在中间加上冒号。两个带有冒号的名称形式意味着“我的分支是左侧的名称,请请求者使用右侧的名称设置他们的分支”。 - torek