-
-
Save takegue/67b3f737c14a14b1cde249ad96da324c to your computer and use it in GitHub Desktop.
Subdirectory checkouts with Git sparse-checkout
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
#!/bin/bash -e | |
CIRCLE_WORKING_DIRECTORY="${CIRCLE_WORKING_DIRECTORY/#\~/$HOME}" | |
[[ ! -d $CIRCLE_WORKING_DIRECTORY ]] && mkdir -p $CIRCLE_WORKING_DIRECTORY | |
cd $CIRCLE_WORKING_DIRECTORY | |
git init | |
git remote add origin $CIRCLE_REPOSITORY_URL | |
git config core.sparsecheckout true | |
[[ -n $FILES ]] && echo $FILES | sed 's/,/\n/g' | tee .git/info/sparse-checkout | |
git fetch --depth=2 origin $CIRCLE_BRANCH | |
git fetch --depth=1 origin HEAD:refs/remotes/origin/HEAD | |
git checkout ${CIRCLE_BRANCH:-${CIRCLE_TAG}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment