2

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.

Sascha Wolf
  • 18,810
  • 4
  • 51
  • 73

3 Answers3

3

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.

Sascha Wolf
  • 18,810
  • 4
  • 51
  • 73
2

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.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • +1. IIRC, completion has undergone several fixes. I would not be surprised if a release made it out with some brokeness. – John Szakmeister Aug 04 '13 at 12:33
  • I just installed the newest version of msysgit but still have the problem. Is there any way to manually install a new bash version? – Sascha Wolf Aug 05 '13 at 07:07
  • @Zeeker not that I know of. What Windows OS version are you using? – VonC Aug 05 '13 at 07:12
  • Im using Windows 7 64bits. – Sascha Wolf Aug 05 '13 at 13:44
  • @Zeeker Strange. Me too. Does the issue persist if you install a portable version of msysgit (https://code.google.com/p/msysgit/downloads/list?can=2&q=portable&colspec=Filename+Summary+Uploaded+ReleaseDate+Size+DownloadCount) somewhere else on your computer? – VonC Aug 05 '13 at 13:46
  • Yes, the problem persists. – Sascha Wolf Aug 05 '13 at 13:51
  • @Zeeker What is the value of your `$HOME` in that gitbash session? And is there any `.bashrc` or `.profile` file in that directory referenced by `$HOME`? – VonC Aug 05 '13 at 13:53
  • The `$HOME` variable is pointing to my home directory (`C:\Users\`). I have a `.profile` file, but this isn't the cause of the problem. I already tried a session without the file but it didn't fix it. – Sascha Wolf Aug 05 '13 at 13:59
  • @Zeeker And what about setting your HOME (temporarily, in the current bash session) to another folder? Would that change anything? I do assume you are using the latest msygit 1.8.3, right? – VonC Aug 05 '13 at 14:04
  • I discovered a solution. I will answer it on a seperate comment. – Sascha Wolf Aug 05 '13 at 14:16
  • @Zeeker I will include it in my answer for more visiblity – VonC Aug 05 '13 at 14:18
0

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

cforbish
  • 8,567
  • 3
  • 28
  • 32