远程分支未显示在"git branch -r"中. [英] Remote branch is not showing up in "git branch -r"
问题描述
我一直在推送到远程Bitbucket存储库,最近一位同事将他创建的新分支推送到了相同的存储库.
I have been pushing to a remote Bitbucket repository and recently a colleague has pushed a new branch he created to the same repository.
我正在尝试获取他上传的更改.
I'm trying to fetch the changes he uploaded.
$ git branch -a
* master
localbranch1
localbranch2
remotes/origin/master
$ git branch -r 来源/主人
$ git branch -r origin/master
在Bitbucket的Web UI中,我可以看到他创建的分支.我该怎么办?
In the web UI for Bitbucket I can see the branch he has made. How can I do this?
下次尝试:
$ git fetch bitbucket
Password for 'https://xxxxx@bitbucket.org':
From https://bitbucket.org/user/repo
* branch HEAD -> FETCH_HEAD
如果他创建的分支称为 new_branch_b ,我应该期望看到以下内容吗?
If the branch he created is called new_branch_b should I be expecting to see the following?
$ git branch -r
origin/master
origin/new_branch_b
第三次尝试:
$ 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
第四次尝试:
[remote "bitbucket"]
url = https://user@bitbucket.org/user/repo.git
我叫远程bitbucket
而不是起源(至少是我想起的;我之前设置过)
I called the remote bitbucket
rather than origin (at least that's what I recall; I set it up a while ago)
第五次尝试:
我按照
$ git config -e
$ git config -e
对于大多数人来说,它被称为起源: For most people it will be called origin: 然后, ....依此类推. 我认为 The (或将 请在此处阅读以下内容: 10.5 Git内部-Refspec Please read about it here: 10.5 Git Internals - The Refspec 这篇关于远程分支未显示在"git branch -r"中.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
[remote "bitbucket"]
url = https://user@bitbucket.org/user/repo.git
fetch = +refs/heads/*:refs/remotes/bitbucket/*
[remote "origin"]
url = https://user@bitbucket.org/user/repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
$ 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
git fetch origin
也可以用于git remote update
.推荐答案
remote
部分还指定了获取规则.您可以在其中添加类似的内容,以从远程获取所有分支:remote
section also specifies fetch rules. You could add something like this into it to fetch all branches from the remote:fetch = +refs/heads/*:refs/remotes/origin/*
origin
替换为bitbucket
.)