git-sync 371 B

1234567891011121314151617181920
  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. [ -e mid-sync ] && sh mid-sync
  12. git push
  13. [ -e post-sync ] && sh post-sync
  14. if git stash list | grep "SYNC SAVE" >/dev/null ; then
  15. git stash pop -q
  16. fi