ambevar-dotfiles/.bin/git-sync

24 lines
382 B
Plaintext
Raw Normal View History

2013-10-06 18:23:00 +02:00
#!/bin/sh
usage () {
cat <<EOF>&2
2013-10-23 10:56:28 +02:00
Usage: ${0##*/} FOLDERS
Sync all git repos found in FOLDERS.
EOF
}
[ $# -eq 0 ] && usage && exit 1
[ "$1" = "-h" ] && usage && exit
[ "$1" = "--" ] && shift
2013-10-23 10:56:28 +02:00
for i; do
2016-10-17 18:52:30 +02:00
status="$(cd -- "$i" && git status -uno)"
if echo "$status" | grep -q "Your branch is ahead of"; then
echo "$i"
echo "$status"
(cd -- "$i" && git push)
echo
fi
2013-10-23 10:56:28 +02:00
done