How to fetch all remote branches?

前端 未结 2 1995
天命终不由人
天命终不由人 2020-12-06 13:10

Somehow one of my repositories refuses to fetch new branches:

C:\\temp>git fetch --all
Fetching origin

C:\\temp>git branch -a
* develop
remotes/origin         


        
相关标签:
2条回答
  • 2020-12-06 13:43

    Check you git config --get remote.origin.fetch refspec.

    It would only fetch all branches if the refspec is

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

    If the refspec is:

    +refs/heads/develop:refs/remotes/origin/develop
    

    Then a fetch would only bring back the develop branch.
    This is typical of a git clone --branch develop --single-branch.

    0 讨论(0)
  • 2020-12-06 14:01

    you can check your branch cat .git/config in terminal

    [core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
    [remote "origin"]
        url = { git remote url }
        fetch = +refs/heads/develop:refs/remotes/origin
    [branch "develop"]
        remote = origin
        merge = refs/heads/develop
    

    and git remote update but not update remote branch. you will replace origin fetch

    first, check remote fetch git config --get remote.origin.fetch

    +refs/heads/develop:refs/remotes/origin/develop
    

    second, unset remote fetch use git config --unset-all remote.origin.fetch and add another git config --add remote.origin.fetch +refs/heads/\*:refs/remotes/origin/feature/\*

    then, you can check replace remote git config --get remote.origin.fetch

    +refs/heads/*:refs/remotes/origin/*
    
    0 讨论(0)
提交回复
热议问题