Git checkout can't auto-complete with bash

I’m using ubuntu with bash. When I typed git checkout then press tab, I expected it would show a list of branches, but I got:

git checkout
bash: eval: line 345: unexpected EOF while looking for matching `''
bash: eval: line 346: syntax error: unexpected end of file

I googled it but found nothing. And bash even doesn’t tell me where is the line 345. Anyone knows what’s wrong?

  • Git Autocompletion looks weird (and only half-functional)
  • RubyMine doesn't recognize gem from git repository
  • How do I enable auto-complete for a git-flow alias?
  • How do I get bash completion to work with aliases?
  • git: hash autocomplete
  • Autocomplete issue while typing git stash show stash@{1}
  • EDIT:

    When I set -x to bash and then git checkout [tab], it outputs:

    +++ case "$c$2" in
    +++ printf '%s
    ' 'feature/capybara '
    +++ for c in '$1'
    +++ case "$c$2" in
    +++ printf '%s
    ' 'feature/chinese-search '
    +++ for c in '$1'
    +++ case "$c$2" in
    +++ printf '%s
    ' 'feature/comment_validation '
    +++ for c in '$1'
    +++ case "$c$2" in
    +++ printf '%s
    ' 'feature/comments '

    …and so on. No error. But I still can’t use autocompletion normally.

  • Can I had git hook files to the repository so everybody has them
  • Releasing a previous Git tag with Maven
  • git verify trusted tags
  • Ruby on Rails in a git hook
  • Git checkout from freshly cloned repository into a branch leads to unstaged changes in that branch
  • GIT able to push the zipped file but get fatal: early EOF when pushing the unzipped contents -
  • One Solution collect form web for “Git checkout can't auto-complete with bash”

    Try set -x in bash:

    -x   Print commands and their arguments as they are executed.

    This should show you what code fails, as it will show what kind of work bash completion does in the background.

    Git Baby is a git and github fan, let's start git clone.