aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-03-15 13:58:57 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-03-15 13:58:57 -0300
commitf7e4c501a1c9e2288ee79440fe745861f4c00c76 (patch)
tree956c2d147d1b9279a9c818215f68d3885d4281b1
parentc17c8c77dbf0de968732262f53b60ced22e80c2a (diff)
downloadscripts-f7e4c501a1c9e2288ee79440fe745861f4c00c76.tar.gz
scripts-f7e4c501a1c9e2288ee79440fe745861f4c00c76.tar.bz2
Adding git-subtree-push
-rwxr-xr-xgit-subtree-push33
1 files changed, 33 insertions, 0 deletions
diff --git a/git-subtree-push b/git-subtree-push
new file mode 100755
index 0000000..41ffe25
--- /dev/null
+++ b/git-subtree-push
@@ -0,0 +1,33 @@
+#!/bin/bash
+#
+# Push changes in a subtree to a remote.
+#
+
+# Parameters
+BASENAME="`basename $0`"
+REMOTE="$1"
+FOLDER="$2"
+
+# Syntax
+if [ -z "$2" ]; then
+ echo "usage: $BASENAME <gitremote> <folder>"
+ exit 1
+fi
+
+# Check remote
+if ! git remote | grep -qe "^$REMOTE"; then
+ echo "fatal: no such remote $REMOTE"
+ exit
+fi
+
+# Fetch the remote
+git fetch $REMOTE master
+
+# Process
+if [ ! -d "$FOLDER" ]; then
+ echo "fatal: folder $FOLDER does not exist"
+ exit 1
+else
+ # Update a subtree
+ git subtree push --prefix=$FOLDER $REMOTE master
+fi