Created
July 17, 2025 13:49
-
-
Save harunhasdal/5197776db30ea20777c1b668d35ccd8a to your computer and use it in GitHub Desktop.
Clone and checkout only a subfolder in a github repository
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
REPO_URL="github url" | |
REPO_NAME="local folder name defaults to repo name" | |
SUBFOLDER_PATH_NO_LEADING_SLASH="path to the folder with no leading slash, but ending with a slash" | |
git clone --depth 1 --no-checkout $REPO_URL | |
cd $REPO_NAME | |
git sparse-checkout set $SUBFOLDER_PATH_NO_LEADING_SLASH | |
git checkout | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment