Last active
January 8, 2022 19:41
-
-
Save nobk/5ee4ed663aa5f915d251675510c0b3d9 to your computer and use it in GitHub Desktop.
git partial clone filtering directories
This file contains hidden or 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
REPONAME="knew" | |
OLDFULLREPO="k8" | |
git init $REPONAME | |
cd $OLDFULLREPO | |
ls -1 > ../${REPONAME}/.git/info/sparse-checkout | |
GITURL="$(git remote show origin | awk '/Fetch URL/ {print $3}')" | |
cd ../$REPONAME | |
nano .git/info/sparse-checkout # remove unwanted dirs | |
git config --local core.sparsecheckout true | |
git remote add origin "$GITURL" | |
git pull origin master | |
git branch --set-upstream-to=origin/master master | |
git pull | |
ls -1 | diff .git/info/sparse-checkout - | |
cd ../${OLDFULLREPO} | |
ls -1 | diff ../${REPONAME}/.git/info/sparse-checkout - |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment