/work/merge_upstream.sh

http://github.com/tybor/Liberty · Shell · 48 lines · 38 code · 9 blank · 1 comment · 4 complexity · 12b3d0abf710a99aa4a63f1cfa92a1a1 MD5 · raw file

  1. #!/bin/bash
  2. cd $(dirname $0)/..
  3. . ./work/tools.sh
  4. list_remotes() {
  5. git remote | egrep -v '^(key|origin|master|local.*)$'
  6. }
  7. branch=$(git branch | awk '/^\*/ {print $2}')
  8. n=$(git remote | wc -l)
  9. title "Fetching branches"
  10. i=0
  11. for remote in $(list_remotes); do
  12. progress 30 $i $n $remote
  13. git fetch $remote
  14. i=$((i+1))
  15. done
  16. progress 30 $i $n done.
  17. echo
  18. title "Switching to upstream branch"
  19. git checkout -q upstream/master
  20. title "Merging branches"
  21. i=0
  22. for remote in $(list_remotes); do
  23. progress 30 $i $n $remote
  24. git merge -q remotes/$remote/master
  25. while [ $(git ls-files -u | wc -l) -gt 0 ]; do
  26. echo
  27. echo "There were conflicts while merging $remote:"
  28. git ls-files -u
  29. echo "Please solve them and press RETURN to continue."
  30. read
  31. done
  32. i=$((i+1))
  33. done
  34. progress 30 $i $n done.
  35. echo
  36. title "Pushing back upstream"
  37. git push upstream
  38. title "Back to branch $branch"
  39. git checkout -q $branch