From: Oleg Broytman Date: Fri, 17 Apr 2020 11:19:19 +0000 (+0300) Subject: Add `sparse-clone` X-Git-Url: https://git.phdru.name/?p=git-scripts.git;a=commitdiff_plain;h=a9ea8ac2e7c82eb7879c3f84a54ef9ff4b312007 Add `sparse-clone` --- diff --git a/sparse-clone b/sparse-clone new file mode 100755 index 0000000..5bbaa6b --- /dev/null +++ b/sparse-clone @@ -0,0 +1,22 @@ +#! /bin/sh +# Adapted from https://stackoverflow.com/a/13738951/7976758 +set -e + +rurl="$1" +localdir="$2" +shift 2 + +mkdir -p "$localdir" +cd "$localdir" + +git init +git remote add origin "$rurl" + +git config core.sparseCheckout true + +# Loops over remaining args +for arg; do + echo "$arg" >> .git/info/sparse-checkout +done + +exec git pull origin master