From: Oleg Broytman Date: Wed, 11 Oct 2017 21:56:56 +0000 (+0300) Subject: Feat: Add `clone` script X-Git-Url: https://git.phdru.name/?a=commitdiff_plain;h=7182410184d8d13645d053bf51cde3b08ad29bb9;p=git-scripts.git Feat: Add `clone` script --- 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