Skip to content

Instantly share code, notes, and snippets.

@afternoon
Created July 8, 2011 15:04
Show Gist options
  • Save afternoon/1072034 to your computer and use it in GitHub Desktop.
Save afternoon/1072034 to your computer and use it in GitHub Desktop.
Sync with a git remote, using git-up if available, pull --rebase if not
#!/bin/sh
changed=`git status -s | wc -l`
if [[ "$changed" -gt "0" ]]; then
echo "\033[31mCan't sync: working tree dirty\033[0m"
else
repo=${1:-origin}
if which -s git-up; then
git up $repo
else
git pull --rebase $repo
fi
git push $repo
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment