Skip to content

Instantly share code, notes, and snippets.

@fbettag
Created June 5, 2011 22:53
Show Gist options
  • Save fbettag/1009512 to your computer and use it in GitHub Desktop.
Save fbettag/1009512 to your computer and use it in GitHub Desktop.
git-sync
[alias]
sync = "!~/path/to/git-sync"
#!/bin/sh
REPODIR=/data/projects
if [ $# -eq 0 ]; then
$0 `dirname $0`
find $REPODIR -type d -name .git -exec $0 {} \;
else
GITDIR="$1"
if [ ! -d $GITDIR ]; then
echo "Directory does not exist."
exit 1
fi
if [ "`basename $GITDIR`" != ".git" ]; then
if [ ! -d $GITDIR/.git ]; then
echo "No .git directory found. Bare repository?"
exit 1
fi
fi
cd $GITDIR
git fetch 2> /dev/null | grep -v "up to date" | grep -v "Done"
git pull 2> /dev/null | grep -v "up to date" | grep -v "Done"
git push --porcelain 2> /dev/null | grep -v "up to date" | grep -v "Done"
git push --porcelain --tags 2> /dev/null | grep -v "up to date" | grep -v "Done"
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment