Skip to content

Instantly share code, notes, and snippets.

@ketansp
Created July 5, 2018 10:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ketansp/d1a2bf726220af1c52a87d76f94e4450 to your computer and use it in GitHub Desktop.
Save ketansp/d1a2bf726220af1c52a87d76f94e4450 to your computer and use it in GitHub Desktop.
git-completion

git-flow completion requires git-completion to work. How exactly you go about installing git-completion varies wildly from system to system, so it's hard to give exact installation instructions.

OS X / macOS

By far the easiest way to install both Git and git-completion is via Homebrew, so you should pick that one.

Homebrew

  1. Install homebrew

  2. Install Git and bash-completion: brew install git && brew install bash-completion (Note: If this install fails with a 404 error, and you already have git installed, just remove the git part of this brew install)

  3. Add bash-completion to your ~/.bash_profile:

    if [ -f `brew --prefix`/etc/bash_completion.d/git-completion.bash ]; then
      . `brew --prefix`/etc/bash_completion.d/git-completion.bash
    fi
    

MacPorts

If you're using MacPorts, then you will need to install Git with the +bash_completion option

sudo port install git +bash_completion

Add the following to your ~/.bash_profile or ~/.profile

# bash-completion
if [ -f /opt/local/etc/profile.d/bash_completion.sh ]; then
  . /opt/local/etc/profile.d/bash_completion.sh
fi

You need to change the command Terminal.app uses to launch the shell in the preferences.

  1. Menu > Preferences > Startup, "Shells open with:"
  2. Select "Command" and enter /opt/local/bin/bash -l to switch to bash provided by MacPorts.

Ubuntu/Debian

  1. Install Git and bash-completion: sudo apt-get install git bash-completion
  2. I don't think you need to do anything else. (This doesn't appear to work on Ubuntu Studio 16.04. For instance 'git flow ' TAB shows the files under bash.)

Fedora

  1. Install Git and bash-completion: sudo yum install git bash-completion
  2. I don't think you need to do anything else.

Arch Linux

  1. Install Git and bash-completion: sudo pacman -S git bash-completion
  2. I don't think you need to do anything else.

Windows

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
    

Note: The steps above have been tested to work with msysgit version 1.7.3.1 and newer, while completion does not function when tested with msysgit version 1.7.0.2. For best results, install the latest version of msysgit.

Cygwin

  1. Download and place git-flow-completion.bash in %CYGWIN_INSTALLATION_DIR%\etc\bash_completion.d
  2. Rename it to git-flow

Now you can autocomplete as following: git flow init etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment