From 820288d1b046f3023b4f5267630e3d5307c90981 Mon Sep 17 00:00:00 2001 From: Oleg Broytman Date: Tue, 20 Dec 2016 22:15:11 +0300 Subject: [PATCH] Add `fork` script to setup upstream and origin remotes --- fork | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100755 fork diff --git a/fork b/fork new file mode 100755 index 0000000..99a8476 --- /dev/null +++ b/fork @@ -0,0 +1,28 @@ +#! /bin/sh + +if [ -z "$2" ]; then + echo "Usage: $0 upstream origin" >&2 + exit 1 +fi + +upstream="$1" +origin="$2" +local_repo="`basename \"$origin\" .git`" + +git clone -o upstream "$upstream" "$local_repo" && +cd "$local_repo" && +git remote add origin "$origin" && + +chmod a-x .git/config && +branch="`git branch | awk '/^\*/ {print $2}'`" && + +git pull origin $branch && +git push -u origin && + +git config branch.$branch.remote upstream && +git config branch.$branch.remotepush origin && +git config branch.$branch.merge refs/heads/$branch && +git config push.default current && + +git gc --aggressive && +exec pwd >> "`dirname \"$0\"`"/locate-all.list -- 2.39.5