Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
466 views
in Technique[技术] by (71.8m points)

git - 如何克隆特定的Git分支? [重复](How do I clone a specific Git branch? [duplicate])

This question already has an answer here:

(这个问题在这里已有答案:)

Git clone will behave copying remote current working branch into local.

(Git clone会将远程当前工作分支复制到本地。)

Is there any way to clone a specific branch by myself without switching branches on the remote repository?

(有没有办法克隆一个特定的分支,而无需在远程存储库上切换分支?)

  ask by Scud translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
git clone -b <branch> <remote_repo>

Example:

(例:)

git clone -b my-branch [email protected]:user/myproject.git

With Git 1.7.10 and later, add --single-branch to prevent fetching of all branches.

(使用Git 1.7.10及更高版本,添加--single-branch以防止获取所有分支。)

Example, with OpenCV 2.4 branch:

(例如,使用OpenCV 2.4分支:)

git clone -b opencv-2.4 --single-branch https://github.com/Itseez/opencv.git

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...