标签云

微信群

扫码加入我们

WeChat QR Code

远程分支没有出现在

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.


git fetch origin & try again

2018年05月27日28分25秒

Hi thanks for your response. I've tried that already, I've updated my question. Would the way be pushed to the repo have anything to do with it?

2018年05月28日28分25秒

Could you show [remote "origin"] section of the .git/config file?

2018年05月27日28分25秒

Done, see Edit 3

2018年05月27日28分25秒

Cool, but maybe it had more sense to use refs/remotes/bitbucket/* instead of refs/remotes/origin/*.

2018年05月27日28分25秒

This fixed my ongoing branching issue in Git that I had for weeks. Suddenly all the git remote update stuff actually started working. Thanks!

2018年05月27日28分25秒

For some reason, it looked like: fetch = +refs/heads/master:refs/remotes/origin/master for me. Replacing master with * fixed my problem.

2018年05月27日28分25秒

The file you need to edit is .git/config

2018年05月27日28分25秒

This is very usefull if you have converted a shallow clone to an unshallow.

2018年05月27日28分25秒

kan Do you know why this sometimes happens? It just happen to me when git clone a project. I don't recall having done anything special with my local git.

2018年05月27日28分25秒

thanks but no joy

2018年05月27日28分25秒

Worked for me. Thanks.

2018年05月27日28分25秒

I'm using the GitHub client on Win and sometimes it doesn't update the remote branches. The first line "git remote update" works like a charm. Easy & clean

1970年01月01日00分03秒

after git remote update I can see the new branch in UI . Thanks

2018年05月27日28分25秒

It worked for me +1. :)

2018年05月28日28分25秒

Was spending so much time to find this answer. This worked without any problem. Thanks. :)

2018年05月27日28分25秒

This worked for me too. Thanks.

2018年05月27日28分25秒

Worked for me as well, pretty strange that this solved it

2018年05月27日28分25秒

git remote -v will show you your remotes so you can get hold of the url, git remote rm origin will remove it, git remote add origin <url> will re-add it.

2018年05月27日28分25秒

Thanks! You're answer actually fixes the issue easily and seems like the correct way to do it. But you should add that the config file is in .git/config, so people can find it.

2018年05月27日28分25秒

Ahh you did. Maybe just highlight the path...

2018年05月27日28分25秒

you can edit the configuration with git config -e

2018年05月27日28分25秒