git-mysync 622 B

123456789101112131415161718192021222324252627282930313233
  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. TEMP=$(mktemp)
  18. git branch -r | cut -d'/' -f2- > "${TEMP}"
  19. git branch --merged | grep -vFf "${TEMP}" | xargs git branch -d
  20. rm "${TEMP}"
  21. git push --all origin
  22. [ -e post-sync ] && sh post-sync
  23. if git stash list | grep "SYNC SAVE" >/dev/null ; then
  24. git stash pop -q
  25. fi