Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. ticket=$1
  4.  
  5. if [[ "$ticket" == "" ]]; then
  6. echo "Usage: $0 <PARTIAL BRANCH NAME>"
  7. exit 1
  8. fi
  9.  
  10. declare -a branches
  11. branches=($(git branch | grep $ticket | tr -d '*'))
  12.  
  13. if [[ ${#branches[@]} -eq 1 ]]; then
  14. git checkout ${branches[0]}
  15. else
  16. echo "hmmm... there are a couple of matching branches:"
  17. IFS="
  18. "; echo "${branches[*]}"
  19. exit 1
  20. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement