git-sync 572 B

123456789101112131415161718192021222324252627
  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 branch --merged | grep -vFf <(git branch -r | cut -d'/' -f2-) | xargs git branch -d
  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