远程分支未显示在"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

[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/*

然后,

$ 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.