Skip to content

Instantly share code, notes, and snippets.

@afirth
Created January 26, 2019 14:31
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save afirth/aef8aebb828cabdb48ae899ff82eb36b to your computer and use it in GitHub Desktop.
Save afirth/aef8aebb828cabdb48ae899ff82eb36b to your computer and use it in GitHub Desktop.
save a subpath of a github repository
#!/usr/bin/env bash
set -eux -o pipefail
tarflags=--strip-components=2
# --wildcards required on linux but not osx
if [ "$(uname)" == "Linux" ]; then
tarflags+=--wildcards
fi
curl -sL https://api.github.com/repos/OWNER/REPO/tarball | \
tar xz $tarflags "*/SUBDIR/*"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment