Git:从主分支以外的分支克隆

编程入门 行业动态 更新时间:2024-10-25 03:28:07
本文介绍了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/repo.git

更多推荐

Git:从主分支以外的分支克隆

本文发布于:2023-11-26 18:35:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634714.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:分支   Git

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!