Git autocomplete in bash aliases?

After using complete -F:

complete -F _git_checkout go

Tabbing after go may result in:

bash: [: 1: unary operator expected

Instead of complete, use __git_complete

This is git bash completion’s built-in function for this purpose.

After declaring your alias, bind the correct auto-complete function to it:

# Main git completions (prior to git 2.30, you an use _git instead of __git_main)
alias g="git"
__git_complete g __git_main

alias go="git checkout"
__git_complete go _git_checkout

alias gp="git push"
__git_complete gp _git_push

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)