How to do submodule sparse-checkout with Git? -
there lot of articles , questions sparse-checkout. unfortunately did not find concrete examples. following example work:
create submodule
cd ~ mkdir sub && cd $_ git init mkdir foo && touch $_/foo mkdir bar && touch $_/bar git add . git commit -am "initial commit"
create project
cd ~ mkdir project && cd $_ git init git submodule add ../sub sub git config -f .gitmodules submodule.sub.shallow true git config -f .gitmodules submodule.sub.sparsecheckout true echo foo/* > .git/modules/sub/info/sparse-checkout git commit -am "initial commit" git submodule update cd sub git checkout .
a point expecting sub
folder contain foo/foo
not bar
. unfortunately doesn't work:
$ ls bar/ foo/
how can make work?
git submodule add
checks out submodule.
what succeeded me was:
git init # did not find way add submodule in 1 step without checking out git clone --depth=1 --no-checkout ../sub sub git submodule add ../sub sub git submodule absorbgitdirs # note there no "submodule.sub.sparsecheckout" key git -c sub config core.sparsecheckout true # note quoted wildcards avoid expansion shell echo 'foo/*' >>.git/modules/sub/info/sparse-checkout git submodule update --force --checkout sub
Comments
Post a Comment