参考资料:
https://stackoverflow.com/questions/600079/how-do-i-clone-a-subdirectory-only-of-a-git-repository
有的时候自己的git仓库写的太臃肿,自己都看的心烦,但是又改不动。
此时如何操作,能实现只git clone很大仓库的一部分,或者说git只监控一部分文件?
mkdir <repo> cd <repo> git init git remote add -f origin <url>
This creates an empty repository with your remote, and fetches all objects but doesn't check them out. Then do:
git config core.sparseCheckout true
Now you need to define which files/folders you want to actually check out. This is done by listing them in .git/info/sparse-checkout
, eg:
echo "some/dir/" >> .git/info/sparse-checkout echo "another/sub/tree" >> .git/info/sparse-checkout
Last but not least, update your empty repo with the state from the remote
git pull origin master标签:info,文件,git,remote,sparse,监控,checkout,origin From: https://www.cnblogs.com/chester-cs/p/17356260.html