Skip to content

Instantly share code, notes, and snippets.

@jcgregorio
Created November 21, 2025 23:36
Show Gist options
  • Select an option

  • Save jcgregorio/614e28695a572e5433379a700ce6bf94 to your computer and use it in GitHub Desktop.

Select an option

Save jcgregorio/614e28695a572e5433379a700ce6bf94 to your computer and use it in GitHub Desktop.
#!/bin/sh
set -e
set -x
# Demonstrate quickly checking out a sparse and shallow clone of a repo,
# applying a change, and pushing it to a new branch.
#
# Generates a random branch name to avoid collisions.
#
# Runs in 1.5 seconds on my machine.
branch=test-$(openssl rand -base64 24)
cd /tmp
git clone https://github.com/goldmine-build/goldmine.git --no-checkout /tmp/goldmine --depth 1
cd /tmp/goldmine
git sparse-checkout init --cone # to fetch only root files
git sparse-checkout set perf/modules/alerts-page-sk # etc, to list sub-folders to checkout
git checkout
git switch -c $branch # or git switch
echo "# test" >> perf/modules/alerts-page-sk/BUILD.bazel
git commit -am "test commit"
git push origin $branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment