How do I clone a single branch in Git?

后端 未结 21 2963
再見小時候
再見小時候 2020-11-22 00:09

I have a local Git repository called \'skeleton\' that I use for storing project skeletons. It has a few branches, for different kinds of projects:

casey@aga         


        
21条回答
  •  傲寒
    傲寒 (楼主)
    2020-11-22 00:37

    Let us take the example of flask repo. It has 3 branches in addition to master. Let us checkout the 1.1.x remote branch

    clone the git repo

    git clone https://github.com/pallets/flask
    

    cd into the repo.

    cd flask
    

    fetch remote branch 1.1.x

    git fetch origin 1.1.x
    

    checkout the branch

    git checkout 1.1.x
    

    You will switch to the branch 1.1.x and it will track the remote 1.1.x branch.

提交回复
热议问题