The entire repository is huge. I am only interested in one of the folders and do not want to clone the entire project repository.
PHPz2017-05-02 09:41:03
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
PHPz2017-05-02 09:41:03
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
PHP中文网2017-05-02 09:41:03
Enter the folder you are interested in and execute git init
初始化这个文件,在clone
to your local area