从git回购叉文件没有克隆回购 [英] Fork file from git repo without cloning the repo
问题描述
有没有一种方法可以从外部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:
- Partial clone with Git and Mercurial
- How to retrieve a single file from specific revision in Git?
- Sparse checkout in Git 1.7.0?
- Is it possible to do a sparse checkout without checking out the whole repository first?
这篇关于从git回购叉文件没有克隆回购的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!