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
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.
$ git fetch bitbucket Password for 'https://firstname.lastname@example.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
$ git remote update Fetching bitbucket Password for 'https://email@example.com': From https://bitbucket.org/user/repo * branch HEAD -> FETCH_HEAD $ git branch -r origin/master
[remote "bitbucket"] url = https://firstname.lastname@example.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)
I updated the bitbucket remote config as per kan's answer.
$ git config -e
[remote "bitbucket"] url = https://email@example.com/user/repo.git fetch = +refs/heads/*:refs/remotes/bitbucket/*
For most people it will be called origin
[remote "origin"] url = https://firstname.lastname@example.org/user/repo.git fetch = +refs/heads/*:refs/remotes/origin/*
$ git remote update Fetching bitbucket Password for 'https://email@example.com': 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.
git fetch origin would also work for
git remote update
Thanks to everyone who helped me with this problem.
git fetch origin & try again
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?
Could you show [remote "origin"] section of the .git/config file?
Done, see Edit 3
Cool, but maybe it had more sense to use refs/remotes/bitbucket/* instead of refs/remotes/origin/*.
This fixed my ongoing branching issue in Git that I had for weeks. Suddenly all the git remote update stuff actually started working. Thanks!
For some reason, it looked like: fetch = +refs/heads/master:refs/remotes/origin/master for me. Replacing master with * fixed my problem.
The file you need to edit is .git/config
This is very usefull if you have converted a shallow clone to an unshallow.
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.
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
after git remote update I can see the new branch in UI . Thanks
It didn't help.
Did not work for me :(
I think I had aleady successfully fetched the branch but just needed to see it listed with git branch -r. On git-scm.com/docs/git-branch it says "Option -r causes the remote-tracking branches to be listed, and option -a shows both local and remote branches". git remote update fetches all branches of all remotes listed in git remote -v.
Was spending so much time to find this answer. This worked without any problem. Thanks. :)
Worked for me as well, pretty strange that this solved it
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.
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.
Ahh you did. Maybe just highlight the path...
you can edit the configuration with git config -e