Remote branch is not showing up in “git branch -r”

前端 未结 5 1249
野性不改
野性不改 2020-12-07 11:17

I have been pushing to a remote Bitbucket repository and recently a colleague has pushed a new branch he created to the same repository.

I\'m trying to fetch the cha

相关标签:
5条回答
  • 2020-12-07 11:55

    Update your remote if you still haven't done so:

    $ git remote update
    $ git branch -r
    
    0 讨论(0)
  • 2020-12-07 12:00

    The remote section also specifies fetch rules. You could add something like this into it to fetch all branches from the remote:

    fetch = +refs/heads/*:refs/remotes/origin/*
    

    (Or replace origin with bitbucket.)

    Please read about it here: 10.5 Git Internals - The Refspec

    0 讨论(0)
  • 2020-12-07 12:01

    I had the same issue. It seems the easiest solution is to just remove the remote, readd it, and fetch.

    0 讨论(0)
  • 2020-12-07 12:09

    If you clone with the --depth parameter, it sets .git/config not to fetch all branches, but only master.

    You can simply omit the parameter or update the configuration file from

    fetch = +refs/heads/master:refs/remotes/origin/master
    

    to

    fetch = +refs/heads/*:refs/remotes/origin/*
    
    0 讨论(0)
  • 2020-12-07 12:15

    Unfortunately, git branch -a and git branch -r do not show you all remote branches, if you haven't executed a "git fetch".

    git remote show origin works consistently all the time. Also git show-ref shows all references in the Git repository. However, it works just like the git branch command.

    0 讨论(0)
提交回复
热议问题