Remote branch not showing up in "git branch
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 remote update
$ git branch -r
I had the same issue. Seems the easiest solution is to just remove the remote, re-add it, and fetch.
链接地址: http://www.djcxy.com/p/3836.html上一篇: git fetch不会获取所有分支
下一篇: 远程分支没有出现在“git分支