从git回购叉文件没有克隆回购 [英] Fork file from git repo without cloning the repo

查看:133
本文介绍了从git回购叉文件没有克隆回购的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以从外部git仓库中分离出一个文件,而无需克隆整个仓库?

解决方案

可以通过使用稀疏结帐来完成此操作意味着使用Git 1.7+,您仍然需要克隆回购(或使用 克隆 - 深度选项来执行浅层克隆)。主要借助这个答案,您可以执行以下操作:

  git clone --no-checkout< URL to git repo> myrepo 
cd myrepo
git config core.sparseCheckout true
vim .git / info / sparse-checkout#添加你想要签出的文件
git checkout<你想要的分支>

如果您的Git版本为1.7.7-rc0或更高版本,则可以使用 clone 命令:
$ b $ pre $ git clone --config core.sparseCheckout = true - -no-checkout< URL to git repo> myrepo

此外,请参阅以下内容:


Is there a way to fork a file from a foreign git repo without cloning the whole repo?

解决方案

The closest you could get to doing this is by using sparse checkout, which means using Git 1.7+ and you still need to clone the repo (or use clone's --depth option to do a shallow clone). Borrowing largely from this answer, you could do the following:

git clone --no-checkout <URL to git repo> myrepo
cd myrepo
git config core.sparseCheckout true
vim .git/info/sparse-checkout # Add files you want checked out
git checkout <branch you want>

If you have Git version 1.7.7-rc0 or later, you can set configuration options with the clone command:

git clone --config core.sparseCheckout=true --no-checkout <URL to git repo> myrepo

Also, see the following:

这篇关于从git回购叉文件没有克隆回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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