我有一个远程裸库中心。我只在总行工作。
下面这个错误消息的最后一句话让我想知道:我如何找到哪个是“当前分支的默认配置远程”?怎么设置呢?
[myserver]~/progs $ git remote -v
hub ~/sitehub/progs.git/ (fetch)
hub ~/sitehub/progs.git/ (push)
[myserver]~/progs $ git branch -r
hub/master
[myserver]~/progs $ cat .git/HEAD
ref: refs/heads/master
[myserver]~/progs $ git pull hub
You asked to pull from the remote 'hub', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
你可以更简单地做到这一点,保证你的.gitconfig处于有意义的状态:
使用Git v1.8.0及以上版本
Git push -u hub master当push时,或:
Git分支-u hub/master
OR
(这将把当前签出分支的远程设置为hub/master)
Git分支——set-up - stream-to - hub/master
OR
(这将把名为branch_name的分支的远程设置为hub/master)
Git分支branch_name——set-upstream-to - hub/master
如果您使用的是v1.7。X或更早
你必须使用——set-upstream:
Git分支——set-upstream master hub/master
获取分支(例如master)的有效推送远程的命令是:
git配置branch大师。pushRemote | | git配置遥控器。布兰奇pushDefault | | git配置远程大师。
以下是原因(来自“man git config”输出):
branch.name.remote[…告诉git从哪个远程获取/推送到[…]] [for push]可能被remote覆盖。pushDefault(所有分支)[和]当前分支[..]被branch.name.pushRemote[…]
出于某种原因,“man git push”只告诉branch.name.remote(即使它是三个中优先级最低的)+错误地声明,如果没有设置,push默认为origin -它没有,只是当你克隆一个repo时,branch.name.remote被设置为origin,但如果你删除这个设置,git push将失败,即使你仍然有origin remote