git 如何克隆或下载一个仓库子文件夹?
某草草
某草草 2017-05-02 09:39:03
0
3
909

整个仓库很庞大,只对其中的一个字文件夹感兴趣,不想将整个项目仓库全都克隆下来。

某草草
某草草

reply all(3)
PHPzhong

The way Git stores files is different from CVS/SVN. When you clone a git repository, you clone all the data in the repository, rather than just the few files you currently need.

Git 1.7.9.5 and later versions allow exporting a single file of a remote repository, such as

git archive --remote=ssh://host/pathto/repo.git HEAD README.md # 导出 README.md 这个文件

If you have performed a clone operation before and the file you need is in the commit history, you can use the git log command to find the hash value of the commit and then execute the following command:

git checkout hash-id path-to-file

Specially, if your code is a public project, you can also do this:

Applicable to Coding

wget https://coding.net/u/user/p/project/git/raw/master/README

For GitHub

wget https://raw.githubusercontent.com/user/project/master/README
PHPzhong

My solution:
Take the https://github.com/geekhac/to... subdirectory as an example:

git init todomvc && cd todomvc

git config core.sparsecheckout true //Set to allow cloning subdirectories

echo '/examples/react/*' >> .git/info/sparse-checkout //Set the subdirectory path of the warehouse to be cloned

git remote add origin https://github.com/geekhac/to...

git pull origin master

Ty80

Enter the folder you are interested in and execute git init初始化这个文件,在cloneto your local area

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!