Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Git configs for a submodule with sparse-checkout filtering
Assuming you have created a submodule 'mysub' in repo 'myrepo'
Set the sparse checkout config property in the submodule
myrepo/.git/modules/mysub/config:
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
worktree = ...path.../myrepo/mysub
ignorecase = true
sparsecheckout = true
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = ...submodule/origin/path...
[branch "master"]
remote = origin
merge = refs/heads/master
Create a sparse-checkout file with rules for the files to be included much as you would with a .gitignore file
myrepo/.git/modules/mysub/info/sparse-checkout:
lib/*.scss
@pathikmehta

This comment has been minimized.

Copy link

@pathikmehta pathikmehta commented Nov 28, 2016

Can we set these sparse checkout configurations

  • sparse checkout parameter to true for submodule
  • Directory paths which you have set in sparse-checkout file

to the remote repository in .gitconfig file or some other place?
Main aim is to set all these configuration in config files so afterward when someone else clone this repository, they get all the configurations available there and they don't need to do all the steps in local which I did to configure sparse checkout in my submodule.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.