File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -95,10 +95,20 @@ reset_wildcard(){
9595
9696# Accepts a pattern and switches to the first branch that matches it.
9797switch_wildcard () {
98+ local all_branches=false
99+ while [[ " $1 " =~ ^- && ! " $1 " == " --" ]]; do case $1 in
100+ -a | --all )
101+ all_branches=true
102+ ;;
103+ esac ; shift ; done
104+ if [[ " $1 " == ' --' ]]; then shift ; fi
105+
98106 if [ -z " $1 " ]; then
99107 echo " No pattern provided"
108+ elif [ " $all_branches " = true ]; then
109+ git branch --all --sort=-committerdate | sed ' s|remotes/origin/||' | egrep " $1 " | head -1 | xargs git switch
100110 else
101- git branch -a | egrep " $1 " | head -1 | xargs git switch
111+ git branch --sort=-committerdate | egrep " $1 " | head -1 | xargs git switch
102112 fi
103113}
104114
You can’t perform that action at this time.
0 commit comments