Git:从主分支以外的分支克隆 [英] Git: Clone from a branch other than master

查看:56
本文介绍了Git:从主分支以外的分支克隆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图从Github的存储库中提取信息.但是我不想克隆master分支.我想克隆其他分支.当我尝试 git clone< url> 时,我从master分支获取了文件.我该怎么办?

I am trying to pull from a repository in Github. But I don't want to clone the master branch. I want to clone some other branch. When I try git clone <url>, I get the files from the master branch. What should I do?

此外,假设代码已在存储库中更新,并且我想获取最新代码,是否应该再次使用 git clone ?因为项目规模巨大.另外,如果我在本地对项目进行更改,然后再次使用git clone,我所做的更改还会存在吗?如果我不希望有更改该怎么办?

Also, suppose the code is updated in the repository and I want to get the latest code, should I again use git clone ? Because the size of the project is huge. Also if I make changes to the project locally, and then I again use git clone, will the changes I made still be there? What if I don't want changes to be there?

我什至不确定 git clone 是正确的命令. git pull git fetch ?

I am not even sure if git clone is the right command. git pull or git fetch?

对不起,我是git的新手.

I am sorry, I am very new to git.

推荐答案

尝试一下:

git init
git fetch url-to-repo branchname:refs/remotes/origin/branchname

编辑

更好的解决方案:

git clone -b mybranch --single-branch git://sub.domain.com/repo.git

这篇关于Git:从主分支以外的分支克隆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆