git-sync 492 B

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