Created
November 9, 2020 17:42
-
-
Save qmchenry/48c036272c0bbdde12bd6c3833b2db5c to your computer and use it in GitHub Desktop.
git interactive branch switcher
This file contains hidden or 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 | |
select branch in $(git branch | cut -c3-) | |
do | |
git switch $branch | |
exit | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install by creating a file with the above contents in your path (like
/usr/local/bin/git-switcher
) and making it executable (chmod +x /usr/local/bin/git-switcher
).Use with
git switcher
in a directory with a repo. The script will list all existing branches indexed by an integer. Selecting a branch by number will switch to that branch.