How to clone all remote branches in Git?

后端 未结 30 2135
情话喂你
情话喂你 2020-11-22 01:08

I have a master and a development branch, both pushed to GitHub. I\'ve cloned, pulled, and fetched, but I re

30条回答
  •  忘了有多久
    2020-11-22 01:40

    Using the --mirror option seems to copy the remote tracking branches properly. However, it sets up the repository as a bare repository, so you have to turn it back into a normal repository afterwards.

    git clone --mirror path/to/original path/to/dest/.git
    cd path/to/dest
    git config --bool core.bare false
    git checkout anybranch
    

    Reference: Git FAQ: How do I clone a repository with all remotely tracked branches?

提交回复
热议问题