How to clone all remote branches in Git?

后端 未结 30 2817
情话喂你
情话喂你 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:45

    Cloning from a local repo will not work with git clone & git fetch: a lot of branches/tags will remain unfetched.

    To get a clone with all branches and tags.

    git clone --mirror git://example.com/myproject myproject-local-bare-repo.git
    

    To get a clone with all branches and tags but also with a working copy:

    git clone --mirror git://example.com/myproject myproject/.git
    cd myproject
    git config --unset core.bare
    git config receive.denyCurrentBranch updateInstead
    git checkout master
    

提交回复
热议问题