]> ruderich.org/simon Gitweb - config/dotfiles.git/commitdiff
bin/updated-git.sh: Add. Syncs git repository with all remotes.
authorSimon Ruderich <simon@ruderich.org>
Sat, 20 Nov 2010 08:57:58 +0000 (09:57 +0100)
committerSimon Ruderich <simon@ruderich.org>
Sat, 20 Nov 2010 08:57:58 +0000 (09:57 +0100)
bin/update-git.sh [new file with mode: 0755]

diff --git a/bin/update-git.sh b/bin/update-git.sh
new file mode 100755 (executable)
index 0000000..83080b9
--- /dev/null
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# Push current commits to all remotes and fetch from all remotes. Then display
+# unmerged commits and changes in the repositories.
+#
+# If an argument is given cd to this directory before running the commands.
+#
+# Very useful to sync multiple remotes.
+
+
+if [ x$1 != x ]; then
+    echo $1
+    cd "$1"
+fi
+
+# Get all remote changes.
+git remote update 2>&1 | grep -v Fetching
+# Push all local changes to remote(s).
+for remote in `git remote`; do
+    git push $remote 2>&1 | grep -v 'Everything up-to-date'
+done
+# Show unmerged changes.
+git branch -rv --color --no-merged
+# Show uncommitted changes.
+if `echo "$1" | grep '\.git\$' > /dev/null`; then
+    cd ..
+fi
+git status | grep 'Changes to be committed:' > /dev/null \
+    && echo '-> modified (staged)'
+git status | grep 'Changed but not updated:' > /dev/null \
+    && echo '-> modified'
+git status | grep 'Untracked files:' > /dev/null \
+    && echo '-> modified (untracked)'
+
+echo