Git 交互式命令无法在 MinGw64 上完成消息"The system cannot find the path specified"



我正在尝试执行git add --patch -- <file>命令从未完成。 MINGW64外壳仅显示"系统找不到指定的路径"。

当通过设置 GIT_TRACE=1 并尝试运行一些组件命令来缩小原因时,我发现错误是由 --interactive 选项引起的,并且无论运行什么 git 命令都可以看到相同的效果。

在以下交互式命令上设置 GIT_TRACE=1 给出了所示的输出:

$ GIT_TRACE=1 git add --interactive -- .gitignore
19:16:47.185964 git.c:350            trace: built-in: git 'add' '--interactive' '--' '.gitignore'
19:16:47.185964 run-command.c:336    trace: run_command: 'add--interactive' '--' '.gitignore'
19:16:47.215964 git.c:564            trace: exec: 'git-add--interactive' '--' '.gitignore'
19:16:47.215964 run-command.c:336    trace: run_command: 'git-add--interactive' '--' '.gitignore'
19:16:47.345964 git.c:350            trace: built-in: git 'rev-parse' '--git-dir'
19:16:47.375964 git.c:350            trace: built-in: git 'rev-parse' '--show-prefix'
19:16:47.405964 git.c:350            trace: built-in: git 'config' '--get-colorbool' 'color.interactive' 'false'
19:16:47.436965 git.c:350            trace: built-in: git 'config' '--get-colorbool' 'color.diff' 'false'
19:16:47.466965 git.c:350            trace: built-in: git 'config' '--get-color' 'reset'
19:16:47.496965 git.c:350            trace: built-in: git 'config' '--get' 'diff.algorithm'
19:16:47.546965 git.c:350            trace: built-in: git 'config' '--bool' '--get' 'diff.compactionheuristic'
19:16:47.576965 git.c:350            trace: built-in: git 'config' '--get' 'interactive.difffilter'
19:16:47.606965 git.c:350            trace: built-in: git 'config' '--bool' '--get' 'interactive.singlekey'
19:16:47.636965 git.c:350            trace: built-in: git 'rev-parse' '--git-dir'
19:16:47.666965 git.c:350            trace: built-in: git 'update-index' '--refresh'
19:16:47.793965 git.c:350            trace: built-in: git 'ls-files' '--' '.gitignore'
The system cannot find the path specified.
19:16:47.843965 git.c:350            trace: built-in: git 'diff-index' '--cached' '--numstat' '--summary' '4b825dc642cb6eb9a060e54bf8d69288fbee4904' '--' '.gitignore'
19:16:47.873966 git.c:350            trace: built-in: git 'diff-files' '--numstat' '--summary' '--raw' '--' '.gitignore'

尝试在没有交互式选项的情况下添加文件按预期工作。 仅当添加了交互式(或修补程序(选项时,操作才会失败。

请注意,我最初在尝试运行该命令时遇到了以下问题:

Can't locate Git.pm in @INC (you may need to install the Git module) (@INC contains: /mingw64/share/perl5/site_perl D:/Apps/StrawberryPerl/perl/site/lib D:/Apps/StrawberryPerl/perl/vendor/lib D:/Apps/StrawberryPerl/perl/lib) at C:Program FilesGitmingw64/libexec/git-coregit-add--interactive line 7.
BEGIN failed--compilation aborted at C:Program FilesGitmingw64/libexec/git-coregit-add--interactive line 7.

但是,将 Git.pm 和 Error.pm 模块复制到perl包含文件夹后,问题更改为此问题顶部描述的问题。

最后,作为进一步的尝试,我在Windows命令提示符(cmd.exe(中运行了该命令,并遇到了完全不同的错误:

c:codeproj>git add --patch .gitignore
error: wrong number of arguments
usage: git config [<options>]
Config file location
--global              use global config file
--system              use system config file
--local               use repository config file
-f, --file <file>     use given config file
--blob <blob-id>      read config from given blob object
Action
--get                 get value: name [value-regex]
--get-all             get all values: key [value-regex]
--get-regexp          get values for regexp: name-regex [value-regex]
--get-urlmatch        get value specific for the URL: section[.var] URL
--replace-all         replace all matching variables: name value 
[value_regex]
--add                 add a new variable: name value
--unset               remove a variable: name [value-regex]
--unset-all           remove all matches: name [value-regex]
--rename-section      rename section: old-name new-name
--remove-section      remove a section: name
-l, --list            list all
-e, --edit            open an editor
--get-color           find the color configured: slot [default]
--get-colorbool       find the color setting: slot [stdout-is-tty]
Type
--bool                value is "true" or "false"
--int                 value is decimal number
--bool-or-int         value is --bool or --int
--path                value is a path (file or directory name)
Other
-z, --null            terminate values with NUL byte
--name-only           show variable names only
--includes            respect include directives on lookup
--show-origin         show origin of config (file, standard input, blob, command line)
config --get-color color.interactive.prompt bold blue: command returned error: 129

我检查了我的 git 配置文件,但我没有设置此选项,所以我猜它是在某处设置的默认值。

除了问题的明显方面(即让--interactive--patch选项按预期工作(之外,我还希望得到有关进一步调试的任何建议或提示。 我使用的各种 TRACE 选项并没有真正突出问题所在,除了向我展示问题所在--interactive选项之外。

简而言之 - 这里的答案是升级 Git for Windows 版本。 我的版本是2.10.1.windows.1,已经有几年的历史了。 我升级到 2.19.0.windows.1,现在一切正常。

所以问题可能是因为该版本的 git 中存在错误,在这种情况下,希望这会给使用该版本的其他人一个提醒。 或者,我的安装可能在某处出现问题,新的 git 安装会自动纠正此问题。 在这种情况下,如果您遇到类似的问题,请考虑尝试一下。

这不是一个特别令人满意的答案 - 但仍然是一个答案。

相关内容

最新更新