From 7182410184d8d13645d053bf51cde3b08ad29bb9 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Thu, 12 Oct 2017 00:56:56 +0300 Subject: [PATCH] Feat: Add `clone` script --- clone | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 clone diff --git a/clone b/clone new file mode 100755 index 0000000..94932f2 --- /dev/null +++ b/clone @@ -0,0 +1,28 @@ +#! /bin/sh + +if [ -z "$1" ]; then + echo "Usage: $0 origin" >&2 + exit 1 +fi + +origin="$1" +local_repo="`basename \"$origin\" .git`" + +if [ -d "$local_repo"/.git ]; then + cd "$local_repo" +fi && + +if [ -d .git ]; then + git remote set-url origin "$origin" +else + git clone -o origin "$origin" "$local_repo" && + cd "$local_repo" +fi && + +pwd >> "`dirname \"$0\"`"/locate-all.list && + +chmod a-x .git/config && +branch="`git rev-parse --abbrev-ref HEAD`" + +git config push.default current && +exec git gc --aggressive -- 2.39.5