I tend to have long branch names for git (e.g., step110_create_search_engine_to_replace_google).
How should I refer to it simply as step110 in checkout/commit statements?
Hold ctrl and left click with the mouse on the branch name. This will prompt a context menu, click Copy. The fast way is to ctrl + double left click so you instantly close the context menu and select the branch name.
The git branch command lets you create, list, rename, and delete branches. It doesn't let you switch between branches or put a forked history back together again. For this reason, git branch is tightly integrated with the git checkout and git merge commands.
If you're on a Unix-like system (Linux, Mac OS X, perhaps others), there's the contrib/complete/git-completion.bash
bash auto-complete ruleset, which will let you auto-complete git commands (you can type git checkout step110<tab>
and your shell will autocomplete the branch-name.
To activate this:
contrib/complete/
there's a file git-completion.bash
. Put that somewhere safe (like ~/.git-completion
), and then add the following line to your ~/.bashrc
file: source ~/.git-completion
. Either restart your shell session or run source ~/.git-completion
to get it running in the current shell session. If you're lucky enough to be using zsh
instead of bash
, I know that oh-my-zsh
has git autocompletion plugins (I'm not sure how to activate them without oh-my-zsh
).
Sources:
Here is how I installed it on OS X...
Check if it's on your local system first. It seems MacPorts and Homebrew download it for you.
$ find / -name "git-completion.bash"
Otherwise, download it...
$ wget https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -O ~/.git-completion
If you don't have wget
, you can install it easily with Homebrew or use cURL.
$ vim ~/.profile
...or your editor of choice.
Then add...
source ~/.git-completion
If your autocompletion doesn't work automatically...
$ source ~/.profile
...and then you have Git autocompletion.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With