简体   繁体   English

Git-bash选项卡完成:“致命:非git存储库:'。git'”(Windows)

[英]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. 我在带有git bash的Windows上使用git,每次我想自动完成git命令中的文件名时,我都会fatal: Not a git repository: '.git'在已经键入的字符和完成的字符之间张贴了fatal: Not a git repository: '.git'

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. 我仍然可以按预期按Enter正确地执行命令。 But it really starts to get on my nerves. 但这真的开始让我紧张。

Any suggestions? 有什么建议么?


The problem was an extra .git -folder in my src folder. 问题是我的src文件夹中有一个额外的.git -folder。 The repository was initialized on the folder above ( src/.. ) and this seemed to mess with git. 该存储库在上面的文件夹( src/.. )上初始化,这似乎与git混为一谈。 After the removal of the extra .git folder the problem disappered. 删除多余的.git文件夹后,问题消失了。

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). 我的src文件夹中有一个额外的.git目录,这似乎与git混淆了(存储库已在上面的文件夹中初始化)。

After I removed the extra .git folder the problem disappered. 我删除了多余的.git文件夹后,问题就消失了。

It can depends on the msysgit version you are using: 它可能取决于您使用的msysgit版本:

I just tested a tab completion on a git diff on W7 64bits, with the latest msysgit1.8.3, and it worked just fine. 我刚刚使用最新的msysgit1.8.3在W7 64位上的git diff上测试了制表符补全,并且工作正常。

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 . 不要忘记,除了msysgit版本之外,由于mysysgit中包含旧的bash 3.1 ,因此选项卡补全也会出现问题。
And the completion can be slow on Windows . 在Windows上完成速度可能很慢


As the OP Zeeker mentions below, the completion git-completion.bash is based on a proper git repo path detection . 就像OP Zeeker 下面提到的那样,完成git-completion.bash是基于适当的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. 在Zeeker的情况下, src文件夹中还有一个额外的.git文件夹 ,这意味着任何完成都基于错误的文件夹,对于git diff ,这是致命的。
git add seems to work though. git add似乎可以工作。

git-bash completion for git commands is controlled by the /etc/git-completion.bash. git命令的git-bash完成由/etc/git-completion.bash控制。 To fix run git-bash as administrator, then: 要以管理员身份运行git-bash,然后:

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 然后从https://github.com/git/git/blob/master/contrib/completion/git-completion.bash的内容创建一个新的

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM