Guest User

Untitled

a guest
May 20th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. Add below code to the file `~/.bashrc`
  2.  
  3. # this will file recent 10 branches
  4. alias recent_branches="git for-each-ref --sort='-authordate:iso8601' --format='%(refname:short)' --count 10 refs/heads"
  5.  
  6. function recent() {
  7. read -a arr <<< $(recent_branches)
  8.  
  9. for ((i = 0; i < ${#arr[@]}; ++i)); do
  10. position=$(($i))
  11. echo "$position ${arr[$i]}"
  12. done
  13. }
  14.  
  15. # checkout to branch with index num
  16. function gckp() {
  17. arr=($(recent_branches))
  18. git checkout ${arr[$@]}
  19. }
Add Comment
Please, Sign In to add comment