我一直在推送到远程Bitbucket存储库,最近一位同事将他创建的一个新分支推送到同一存储库。
我在试着获取他上传的更改。
$ git branch -a
* master
localbranch1
localbranch2
remotes/origin/master
$ git分支-r源站/主站
在Bitbucket的web UI中,我可以看到他创建的分支。我该怎么做呢?
下一次尝试:
$ git fetch bitbucket
Password for 'https://xxxxx@bitbucket.org':
From https://bitbucket.org/user/repo
* branch HEAD -> FETCH_HEAD
如果他创建的分支名为new_branch_b,我应该看到以下内容吗?
$ 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
而不是源(至少我记得是这样的;我在一段时间之前设置了它)
第五次尝试:
我根据kan's answer更新了Bitbucket远程配置
$ git配置-e
[remote "bitbucket"]
url = https://user@bitbucket.org/user/repo.git
fetch = +refs/heads/*:refs/remotes/bitbucket/*
对于大多数人来说,它将被称为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 remote update
也可以使用git fetch origin
。
发布于 2012-09-07 23:17:10
remote
部分还指定了获取规则。您可以向其中添加类似以下内容的内容,以便从远程获取所有分支:
fetch = +refs/heads/*:refs/remotes/origin/*
(或者用bitbucket
替换origin
。)
请在这里阅读:
发布于 2012-09-07 22:40:15
如果您仍未更新遥控器,请执行以下操作:
$ git remote update
$ git branch -r
发布于 2017-07-26 17:08:25
如果使用--depth
参数进行克隆,它会将.git/config
设置为不获取所有分支,而只获取主分支。
您可以简单地省略参数或更新配置文件
fetch = +refs/heads/master:refs/remotes/origin/master
至
fetch = +refs/heads/*:refs/remotes/origin/*
https://stackoverflow.com/questions/12319968
复制相似问题