Skip to content

Instantly share code, notes, and snippets.

@hoyangtsai
Last active March 26, 2020 02:19
Show Gist options
  • Save hoyangtsai/29a27a97fb6b96a74c7cf86a524fc951 to your computer and use it in GitHub Desktop.
Save hoyangtsai/29a27a97fb6b96a74c7cf86a524fc951 to your computer and use it in GitHub Desktop.
git spare-checkout clone subdirectory
# create a directory for the project repo
mkdir [project_name] && cd [project_name]
# initialize git repo
git init
# enable git subtree checkout
git config core.sparsecheckout true
# enter a folder name which is checked out
echo '[folder_name]' >> .git/info/sparse-checkout
# set and fetch the git repository
git remote add -f origin [git_repo_url]
# pull out the files
git pull origin [branch_name]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment