Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Add below code to the file `~/.bashrc`
- # this will file recent 10 branches
- alias recent_branches="git for-each-ref --sort='-authordate:iso8601' --format='%(refname:short)' --count 10 refs/heads"
- function recent() {
- read -a arr <<< $(recent_branches)
- for ((i = 0; i < ${#arr[@]}; ++i)); do
- position=$(($i))
- echo "$position ${arr[$i]}"
- done
- }
- # checkout to branch with index num
- function gckp() {
- arr=($(recent_branches))
- git checkout ${arr[$@]}
- }
Add Comment
Please, Sign In to add comment