2 July, 2023

Git trick: commit without cloning a repo

After lots of trial-and-error, this SO answer taught me how to invoke an incantation called sparse checkouts, allowing me to bypass downloading an entire monster monorepo just to make a few changes.

git clone -n --filter=tree:0 --depth=1 REMOTE_URL DIR
cd DIR
git sparse-checkout set --no-cone YOUR_DIRECTORY/A_SUBDIRECTORY_TOO
mkdir -p YOUR_DIRECTORY/A_SUBDIRECTORY_TOO
git add YOUR_DIRECTORY/A_SUBDIRECTORY_TOO
# branch, commit, and push as usual!