git-sync 484 B

1234567891011121314151617181920212223242526
  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. if [ -d .git/annex ] ; then
  9. echo "In an annex repository"
  10. git annex sync
  11. exit
  12. fi
  13. [ -e pre-sync ] && sh pre-sync
  14. git stash push -u -m "SYNC SAVE"
  15. git pull --all
  16. [ -e mid-sync ] && sh mid-sync
  17. git push --all origin
  18. [ -e post-sync ] && sh post-sync
  19. if git stash list | grep "SYNC SAVE" >/dev/null ; then
  20. git stash pop -q
  21. fi