我看不到我的远程分支

时间:2012-09-25 08:05:28

标签: git

在等待系统管理员设置gerrit repo时,我创建了自己的分支。他刚刚给我发了回购地址。我把它设置为原点并以某种方式推动了我的最后一次提交。 克隆repo工作正常,但git branch -r不返回任何内容。这里发生了什么?

$ git init
# made some comits    
git config remote.origin.url ssh://gerrit.mm-sol.com/branchname

$ git push origin SH1-of-my-last-commit:master    
error: unable to push to unqualified destination: master    
The destination refspec neither matches an existing ref on the remote nor  
begins with refs/, and we are unable to guess a prefix based on the source ref.  
error: failed to push some refs to 'ssh://gerrit.mm-sol.com/apps/phone-shaker'  

$ git push origin master
Counting objects: 85, done.  
Delta compression using up to 4 threads.  
Compressing objects: 100% (85/85), done.  
Writing objects: 100% (85/85), 20.95 KiB, done.  
Total 85 (delta 49), reused 0 (delta 0)  
remote: Resolving deltas: 100% (49/49)   
remote: Updating references: 100% (1/1)  
To ssh://gerrit.mm-sol.com/branchname  
 * [new branch]      master -> master  

2 个答案:

答案 0 :(得分:22)

试试这个:

git config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
git fetch origin

然后再次尝试git branch -r

将来设置遥控器时,最好使用以下命令而不是git config

git remote add <remotename> <remoteurl>

e.g。

git remote add origin ssh://gerrit.mm-sol.com/branchname

这会自动设置urlfetch配置。

答案 1 :(得分:1)

尝试git push -u origin master