X-Git-Url: https://git.phdru.name/?a=blobdiff_plain;f=sparse-clone;fp=sparse-clone;h=5bbaa6b982ec2f9af1c2a31b60d7a46e96449439;hb=a9ea8ac2e7c82eb7879c3f84a54ef9ff4b312007;hp=0000000000000000000000000000000000000000;hpb=467b1c39d782a3f2d0b31d73033a0af952896295;p=git-scripts.git 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