Guest User

Untitled

a guest
Dec 18th, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. I="\e[96m"
  3. E="\e[90m"
  4.  
  5. echo -e "🤖$I starting sync.. $E";
  6.  
  7. CURRENT_BRANCH="`git rev-parse --abbrev-ref HEAD`"
  8. STASH_RESULT="`git stash push -u -m AUTO_STASH | grep Saved`"
  9.  
  10. if [ -n "$STASH_RESULT" ]; then
  11. echo -e "🤖$I stashed changes to AUTO_STASH $E";
  12. fi
  13.  
  14. git fetch --all -p
  15.  
  16. LOCAL_BRANCHES=`git branch | cut -c 3-`;
  17. BRANCHES_WITH_REMOTES=`git for-each-ref --format '%(refname:short):%(upstream:short)' 'refs/heads' | grep -v ':$'`;
  18.  
  19. echo $BRANCHES_WITH_REMOTES | while IFS=: read local remote; do
  20. echo -e "🤖$I running git checkout $local $E"
  21. git checkout $local || return 1;
  22. echo -e "🤖$I running git pull $E"
  23. git pull;
  24. done
  25.  
  26. echo $LOCAL_BRANCHES | while IFS=: read local; do
  27. echo -e "🤖$I running git checkout $local $E"
  28. git checkout $local || return 1;
  29. echo -e "🤖$I merging $local with master $E"
  30. git merge master || return 1;
  31. done
  32.  
  33. echo -e "🤖$I checkingout starting branch $CURRENT_BRANCH $E"
  34.  
  35. git checkout $CURRENT_BRANCH
  36.  
  37. if [ -n "$STASH_RESULT" ]; then
  38. git stash pop;
  39. else
  40. echo -e "🤖$I no changes found. skipping stash pop $E";
  41. fi
Add Comment
Please, Sign In to add comment