From a9ea8ac2e7c82eb7879c3f84a54ef9ff4b312007 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Fri, 17 Apr 2020 14:19:19 +0300 Subject: [PATCH] Add `sparse-clone` --- sparse-clone | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 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 -- 2.39.5