How do I clone a single branch in Git?

后端 未结 21 2911
再見小時候
再見小時候 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

    One way is to execute the following.

    git clone user@git-server:project_name.git -b branch_name /your/folder
    

    Where branch_name is the branch of your choice and "/your/folder" is the destination folder for that branch. It's true that this will bring other branches giving you the opportunity to merge back and forth.

    Update

    Now, starting with Git 1.7.10, you can now do this

    git clone user@git-server:project_name.git -b branch_name --single-branch /your/folder
    

提交回复
热议问题