]> git.phdru.name Git - git-scripts.git/commitdiff
Add fork-existing
authorOleg Broytman <phd@phdru.name>
Tue, 30 May 2017 14:23:23 +0000 (17:23 +0300)
committerOleg Broytman <phd@phdru.name>
Tue, 30 May 2017 14:23:23 +0000 (17:23 +0300)
fork-existing [new file with mode: 0755]

diff --git a/fork-existing b/fork-existing
new file mode 100755 (executable)
index 0000000..20e4685
--- /dev/null
@@ -0,0 +1,26 @@
+#! /bin/sh
+
+if [ -z "$2" ]; then
+   echo "Usage: $0 upstream origin" >&2
+   exit 1
+fi
+
+upstream="$1"
+origin="$2"
+
+pwd >> "`dirname \"$0\"`"/locate-all.list &&
+git remote add upstream "$upstream" &&
+git remote set-url 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 &&
+
+exec git gc --aggressive