Created
August 20, 2020 18:41
-
-
Save emacdona/5cabed252a0af733a4e06491136bec10 to your computer and use it in GitHub Desktop.
Ever get tired of having to type out branch names when you're trying to switch between local branches? This four line function will prompt you for a number instead (warning: uses zsh function and 'read' builtin syntax; you'll need to modify for bash).
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
# "checkout". Shows you local git branches and prompts you to select one by ordinal | |
co() { | |
echo "Which branch do you want to switch to?" | |
git branch | cat -n | |
read "NUM?> " | |
git checkout $(git branch | head -n $NUM | tail -n 1) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment