git shallow clone (clone --depth) misses remote branches

前端 未结 3 1019
误落风尘
误落风尘 2020-11-28 01:42

After cloning a remote repository it does not show any remote branch by -a option. What could be the problem? How to debug it? In this snippet two of the remote branches are

3条回答
  •  我在风中等你
    2020-11-28 02:37

    After doing a shallow clone, to be able to checkout other branches from remote,

    1. Run (thanks @jthill):

      git remote set-branches origin '*'
      
    2. After that, do a git fetch -v

    3. Finally git checkout the-branch-i-ve-been-looking-for


    Step 1 can also be done manually by editing .git/config.

    For instance, change the folloing line from:

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

    to (replace master with *):

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

提交回复
热议问题