Alex Wolf
Alex Wolf

Reputation: 20128

Git-bash tab completion: "fatal: Not a git repository: '.git'" (Windows)

I'm using git on windows with the git bash and every time I want to autocomplete a filename in a git command I get fatal: Not a git repository: '.git' posted between my already typed characters and the completed ones.

It looks like this:

$ git diff a
<using tab>
$ git diff afatal: Not a git repository: '.git'
pp.js

I can still make the command properly by just pressing enter as expected. But it really starts to get on my nerves.

Any suggestions?


The problem was an extra .git-folder in my src folder. The repository was initialized on the folder above (src/..) and this seemed to mess with git. After the removal of the extra .git folder the problem disappered.

Upvotes: 2

Views: 1500

Answers (3)

VonC
VonC

Reputation: 1323793

It can depends on the msysgit version you are using:

I just tested a tab completion on a git diff on W7 64bits, with the latest msysgit1.8.3, and it worked just fine.

Don't forget that, in addition to the msysgit version, you will have issues with tab completion due to the old bash 3.1 included in mysysgit.
And the completion can be slow on Windows.


As the OP Zeeker mentions below, the completion git-completion.bash is based on a proper git repo path detection.

# __gitdir accepts 0 or 1 arguments (i.e., location)
# returns location of .git repo
__gitdir () {
...
}

And in Zeeker's case, an extra .git folder was in the src folder, which means any completion was based from the wrong folder, which, for git diff, proved fatal.
git add seems to work though.

Upvotes: 2

Alex Wolf
Alex Wolf

Reputation: 20128

I just discoverd the solution. I had an extra .git directory in my src-folder which seemed to mess with git (the repository was initialised on the folder above).

After I removed the extra .git folder the problem disappered.

Upvotes: 3

cforbish
cforbish

Reputation: 8819

git-bash completion for git commands is controlled by the /etc/git-completion.bash. To fix run git-bash as administrator, then:

cd /etc
mv /etc/git-completion.bash /etc/git-completion.bash.orig

Then create a new one from the contents of https://github.com/git/git/blob/master/contrib/completion/git-completion.bash

Upvotes: 0

Related Questions