Skip to content

Instantly share code, notes, and snippets.

@dawu76
Created April 6, 2023 16:25
Show Gist options
  • Save dawu76/cf6d64788d442999dc6b284ec6b519a3 to your computer and use it in GitHub Desktop.
Save dawu76/cf6d64788d442999dc6b284ec6b519a3 to your computer and use it in GitHub Desktop.
sparse git checkout
# clone only basic branch details / metadata & checkout only root dir
git clone --filter=blob:none --sparse  %your-git-repo-url%
cd %your-local-github-repo%
# can checkout sub-directory or individual file
git sparse-checkout add %subdirectory-to-be-cloned%
$ git clone --filter=blob:none --sparse [email protected]:hwchase17/langchain.git
$ cd langchain/
$ git sparse-checkout add docs

Can commit & push changes as usual

git checkout -b %new-branch-name% origin/%parent-branch-name% 
git commit -m "Initial changes in sparse clone branch"
git push origin %new-branch-name%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment