I want to change git branches by it's number
To show branches numbers I use this (with alias):
$ git br | nl
1 * master
2 test
Now I want to get branch name by it's number and pass it to git checkout:
echo $(git branch | sed "s|[* ]||g;$1q;d") | xargs git checkout
But how to pass '$1' from args to this command, supposing it have an alias?
Expected behaviour:
alias checkout='echo $(git branch | sed "s|[* ]||g;$1q;d") | xargs git checkout'
checkout 2 # checkout to branch test