Skip to content

Instantly share code, notes, and snippets.

@johnhunter
Created August 12, 2012 18:14
Show Gist options
  • Star 14 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save johnhunter/3333533 to your computer and use it in GitHub Desktop.
Save johnhunter/3333533 to your computer and use it in GitHub Desktop.
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
Copy link

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