This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#First create a repo | |
mkdir A && cd A && git init && touch a.dev && touch a.prod && git add -A && git commit -m 'init A' && cd ../ | |
#Lets create another repo that will use A as submodule with sparse-checkout | |
mkdir B && cd B && git init && touch b && git add -A && git commit -m 'init B' | |
#Now we will clone A as submodule of B and will say that file/dir we only want to use in B | |
git submodule add ../A/ A && cd A && git config core.sparsecheckout true && echo a.prod >> ../.git/modules/A/info/sparse-checkout && git read-tree -mu HEAD && cd ../ && git add -A && git commit -m 'add A as submodule/sparse-checkout' && cd ../ |