远程分支没有显示在“git branch -r”中 [英] Remote branch not showing up in "git branch -r"

查看:1191
本文介绍了远程分支没有显示在“git branch -r”中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在推动一个远程bitbucket回购,最近一位同事将他创建的一个新分公司推到了同一个回购站。

我正在尝试获取他上传的更改。

  $ git分支-a 
*主人
localbranch1
localbranch2
遥控器/ origin / master




$ git分支-r

origin / master

在用于bitbucket的web ui中,我可以看到他所创建的分支。任何帮助/建议/方向将不胜感激。谢谢。



您需要的任何进一步信息只需要询问。

编辑1

  $ git fetch bitbucket 
'https://xxxxx@bitbucket.org'的密码:
From https://bitbucket.org/user/repo
* branch HEAD - > FETCH_HEAD

如果他创建的分支名为 new_branch_b ,我应该期待请参阅:

$ $ p $ $ $ $ $ c $ $ git分支-r
原点/主$ b $原点/ new_branch_b

编辑2

  $ git remote update 
获取bitbucket
'https://xxxxx@bitbucket.org'的密码:
从https://bitbucket.org/user/ repo
*分支HEAD - > FETCH_HEAD


$ git分支-r
来源/主

编辑3

  [远程bitbucket] 
url = https ://user@bitbucket.org/user/repo.git

我称远程bitbucket而不是(至少这是我记得的,我刚刚设置它)



编辑4



根据kan的回答更新了bitbucket远程配置。


$ git config -e




  [remotebitbucket] 
url = https://user@bitbucket.org/user/ repo.git
fetch = + refs / heads / *:refs / remotes / bitbucket / *



<对于大多数人来说,它将被称为来源

  [远程起源] 
url = https:// user@bitbucket.org/user/repo.git
fetch = + refs / heads / *:refs / remotes / origin / *

之后

  $ git remote update 

获取bitbucket
'https://user@bitbucket.org'的密码:
remote:计数对象:48,完成。
remote:压缩对象:100%(32/32),完成。
remote:合计35(增量21),重用0(增量0)
开箱对象:100%(35/35),完成。
从https://bitbucket.org/user/repo
* [新分支] branch_name1 - > origin / branch_name1
* [新分支] branch_name2 - > origin / branch_name2

....等等。



我认为 git fetch origin 也适用于 git远程更新



感谢所有帮助我解决这个问题的人。 远程部分也指定提取规则。 您可以添加类似的内容:

  fetch = + refs / heads / *:refs / remotes / origin / * 

从远程获取所有分支。 (或者用 bitbucket 来替换 origin )。



请在这里阅读: https://git-scm.com/ book / en / v2 / Git-Internals-The-Refspec

I have been pushing to a remote bitbucket repo and recently a colleague has pushed a new branch he created to the same repo.

I'm trying to fetch the changes he uploaded.

 $ git branch -a  
 * master 
 localbranch1
 localbranch2
 remotes/origin/master

$ git branch -r
origin/master

In the web ui for bitbucket I can see the branch he has made. Any help/advice/direction would be most appreciated. Thanks.

Any futher info you need just ask.

EDIT 1

$ git fetch bitbucket
Password for 'https://xxxxx@bitbucket.org':
From https://bitbucket.org/user/repo
 * branch            HEAD       -> FETCH_HEAD

If the branch he created is called new_branch_b should I be expecting to see:

$ git branch -r    
origin/master 
origin/new_branch_b

EDIT 2

$ git remote update
Fetching bitbucket
Password for 'https://xxxxx@bitbucket.org':
From https://bitbucket.org/user/repo
 * branch            HEAD       -> FETCH_HEAD


$ git branch -r
  origin/master

EDIT 3

[remote "bitbucket"]
url = https://user@bitbucket.org/user/repo.git

I called the remote bitbucket rather than origin (at least that's what I recall, I set it up a while ago)

EDIT 4

I updated the bitbucket remote config as per kan's answer.

$ git config -e

[remote "bitbucket"]
    url = https://user@bitbucket.org/user/repo.git
    fetch = +refs/heads/*:refs/remotes/bitbucket/*

For most people it will be called origin

[remote "origin"]
    url = https://user@bitbucket.org/user/repo.git
    fetch = +refs/heads/*:refs/remotes/origin/*

Afterwards

$ git remote update

Fetching bitbucket
Password for 'https://user@bitbucket.org':
remote: Counting objects: 48, done.
remote: Compressing objects: 100% (32/32), done.
remote: Total 35 (delta 21), reused 0 (delta 0)
Unpacking objects: 100% (35/35), done.
From https://bitbucket.org/user/repo
 * [new branch]      branch_name1 -> origin/branch_name1
 * [new branch]      branch_name2    -> origin/branch_name2

.... and so on.

I think git fetch origin would also work for git remote update

Thanks to everyone who helped me with this problem.

解决方案

The remote section specifies also fetch rules. You could add something like into it:

fetch = +refs/heads/*:refs/remotes/origin/*

to fetch all branches from the remote. (or replace origin by bitbucket).

Please read about it here: https://git-scm.com/book/en/v2/Git-Internals-The-Refspec

这篇关于远程分支没有显示在“git branch -r”中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆