如何获取远程Git存储库的一个分支? [英] How do I fetch only one branch of a remote Git repository?

查看:125
本文介绍了如何获取远程Git存储库的一个分支?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想抓取远程存储库的一个分支(不是所有分支),并创建一个本地跟踪分支,以跟踪对该远程分支的更多更新。远程存储库中的其他分支非常大,所以我想避免提取它们。我怎么做到的?

I'd like to grab a single branch (not all of them) of a remote repository and create a local tracking branch that can track further updates to that remote branch. The other branches in the remote repository are very big, so I'd like to avoid fetching them. How do I do this?

编辑:我自己想出了这个,但StackOverflow拒绝让我提供答案作为答案,所以我会把它放在这里的问题

I figured this out myself but StackOverflow refuses to let me provide the answer as an answer so I'll put it here in the question instead.

您使用-t选项来进行远程添加,例如:

You use the -t option to git remote add, e.g.:

git remote add -t remote-branch remote-name remote-url

您可以使用多个 -t分支选项来获取多个分支。

You can use multiple "-t branch" options to grab multiple branches.

推荐答案

git fetch <remote_name> <branch_name>

为我工作。

这篇关于如何获取远程Git存储库的一个分支?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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