Cloning specific branch

前端 未结 7 867
南笙
南笙 2021-01-31 09:40

I am new to git version control and I dont know how to clone / pull a specific branch of a repo . Trying to get the branch master of the project, but it defaults to

7条回答
  •  孤街浪徒
    2021-01-31 09:54

    You can use the following flags --single-branch && --depth to download the specific branch and to limit the amount of history which will be downloaded.

    You will clone the repo from a certain point in time and only for the given branch

    git clone -b  --single-branch  --depth 
    

    --[no-]single-branch


    Clone only the history leading to the tip of a single branch, either specified by the --branch option or the primary branch remote’s HEAD points at.

    Further fetches into the resulting repository will only update the remote-tracking branch for the branch this option was used for the initial cloning. If the HEAD at the remote did not point at any branch when --single-branch clone was made, no remote-tracking branch is created.


    --depth

    Create a shallow clone with a history truncated to the specified number of commits

提交回复
热议问题