git只监控一部分文件

  参考资料:

  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
posted @ 2023-05-17 13:24  思念殇千寻  阅读(39)  评论(0编辑  收藏  举报