我一直在推送到远程Bitbucket存储库,最近一位同事将他创建的新分支推送到了相同的存储库。
我正在尝试获取他上传的更改。
$ git branch -a
* master
localbranch1
localbranch2
remotes/origin/master
$ git branch -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的回答更新了Bitbucket远程配置:
$ git config -e
[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。
谢谢,适当地提到了命名一致性。不过,将bitbucket更改为原点可能更有意义!公约及所有其他:)
—
feargal 2012年
git fetch origin做这份工作
refs/remotes/bitbucket/*代替可能更有意义refs/remotes/origin/*。