git-sync 340 B

12345678910111213141516171819
  1. #!/bin/sh
  2. if ! GITDIR=$(git rev-parse --git-dir) ; then
  3. echo "Not in a git repository" >&2
  4. exit 0
  5. fi
  6. TREE=$(dirname $GITDIR)
  7. cd $TREE
  8. [ -e pre-sync ] && sh pre-sync
  9. git stash push -u -m "SYNC SAVE"
  10. git pull
  11. git push
  12. [ -e post-sync ] && sh post-sync
  13. if git stash list | grep "SYNC SAVE" >/dev/null ; then
  14. git stash pop -q
  15. fi