Search code examples
gitbashposh-git

How do I add autocomplete to git aliases?


I have setup git autocomplete using the git-autocomplete.bash file which works for standard commands and simple aliases (co = checkout), but I have a longer alias defined in my .git-config file that I would like to autocomplete branch names on and I cannot find how to do this.

I am on Windows Server 2012 R2 running git 2.10.2.windows.1

My alias looks like this:

mstage = "!git checkout stage && git pull && git reset --hard && git merge $1 --no-commit"

where $1 is a branch name - I'd love this to autocomplete


Solution

  • here we have two options for windows operating system:

    msysgit

    1. Download and place git-flow-completion.bash in home directory (~/ in msysgit shell)
    2. Add a .bashrc file to your home directory with the following line (or add this line to existing .bashrc file):

      source ~/git-flow-completion.bash

    Cygwin

    1. Download and place git-flow-completion.bash in

      %CYGWIN_INSTALLATION_DIR%\etc\bash_completion.d

    2. Rename it to git-flow

      you can autocomplete as following: git flow init etc.