git config --global alias.checkoutr checkout
$EDITOR /usr/local/share/zsh/site-functions/git-completion.bash...and then modify the file as follows...
-__gitcomp_nl "$(__git_refs '' $track)"
+if [ "$command" = "checkoutr" ]; then
+ __gitcomp_nl "$(__git_refs '' $track)"
+else
+ __gitcomp_nl "$(__git_heads '' $track)"
+fi... and source your shell (source ~/.bashrc / source ~/.zshrc...).
Use git checkoutr for the default behavior and git checkout (or just gco) for browsing only local branches. Credits to http://cmetcalfe.ca/blog/git-checkout-autocomplete-local-branches-only.html.
I've added the amended
_git_checkout ()function in my.zshrcfile, but the function doesn't work unless I manuallysourcefor every new terminal session.I assume this is because the
gitplugin is loaded after the redeclaration, is there a way around this? Currently, I've amended thegit-completion.bashfile manually.