Git - clone only part of the repository and get pulls only for that part?

给你一囗甜甜゛ 提交于 2019-12-01 09:28:50
VonC

You can make a sparse checkout for each repos:

mkdir repo1
cd myrepo1
git init
git config core.sparseCheckout true
git remote add -f origin /url/of/repo1
echo module1/*> .git/info/sparse-checkout
git fetch
git checkout master

(same for repo2)

For the record I will add my dilemma where I wanted all files in the root folder of the repository and two of the subdirs, but not the other two (very large) dirs. This is what I came up with after also looking here

git init SOME_REPO
cd SOME_REPO/
git remote add origin ssh://<git server>:<port>/SOME_REPO
git config core.sparsecheckout true
echo '/*' >> .git/info/sparse-checkout
echo '!first_not_wanted_dir/*' >> .git/info/sparse-checkout
echo '!second_not_wanted_dir/*' >> .git/info/sparse-checkout
git pull --depth=1 origin master
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!