Created
August 12, 2019 10:25
-
-
Save YossiCohen/69676e653681fcad9de821a140d2c871 to your computer and use it in GitHub Desktop.
Smart git checkout command - lists branches with filter and allows selection of desired branch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Usage: gitCheckoutFilter.sh [filter] | |
# will list all branches with the relevant filter (grep) and allow branch selection | |
# i.e. | |
# ~/gitCheckoutFilter.sh yo | |
# 1) yossi_main | |
# 2) yossi_panel_redesign | |
##? 1 | |
# Switched to branch 'yossi_main' | |
branches=`git branch | grep -i $1` | |
branches=${branches//\*/} | |
select branch in $branches; | |
do | |
git checkout $branch | |
exit | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment