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:
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
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:Specially, if your code is a public project, you can also do this:
Applicable to Coding
For GitHub
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
Enter the folder you are interested in and execute
git init
初始化这个文件,在clone
to your local area