ambevar-dotfiles/.scripts/git-sync

26 lines
442 B
Plaintext
Raw Normal View History

2013-10-06 18:23:00 +02:00
#!/bin/sh
if [ $# -eq 0 ] || [ "$1" = "-h" ]; then
cat<<EOF
2013-10-23 10:56:28 +02:00
Usage: ${0##*/} FOLDERS
Sync all git repos found in FOLDERS.
EOF
exit
2013-10-23 10:56:28 +02:00
fi
for i; do
while IFS= read -r FOLDER; do
ROOT="${FOLDER%/*}"
STATUS="$(cd -- "$ROOT" && git status -uno | grep "Your branch is ahead of")"
if [ -n "$STATUS" ]; then
echo "$ROOT"
echo "$STATUS"
(cd -- "$ROOT" && git push)
echo
fi
done <<EOF
2013-10-23 10:56:28 +02:00
$(find "$i" -type d -name ".git")
2013-10-06 18:23:00 +02:00
EOF
2013-10-23 10:56:28 +02:00
done