Created
June 5, 2011 22:53
-
-
Save fbettag/1009512 to your computer and use it in GitHub Desktop.
git-sync
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[alias] | |
sync = "!~/path/to/git-sync" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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