git checkout(Windows 10 / mingw64)错误,显示“无此文件或目录”

迈克·克劳

尝试使用在Linux上开发的项目在Windows 10中进行开发。代码存储在GitLab中,并且在多个存储库中看到以下错误。使用git版本2.15.1.windows.2

这是一个例子:

→ git pull
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (5/5), done.
From myurl:project/master
   c23fc916..6dd18de8  master     -> origin/master
error: unable to create file test/template/PRN.template: No such file or directory
Updating c23fc916..6dd18de8

绝对不是长路径(较长的文件名已签出,并且我已移动目录以缩短总长度):

→ git config --system -l
...
core.longpaths=true

此外,它在出错之前在该目录中写入了其他3个文件:

→ ls -1 test/template/
'Complex Testing Scenario.template'
create_from_template.py
Scheduled.template

如果使用GIT_TRACE,则会看到:

→ GIT_TRACE=1 git pull
18:16:13.337044 git.c:344               trace: built-in: git 'pull'
18:16:13.342045 run-command.c:626       trace: run_command: 'fetch' '--update-head-ok'
18:16:13.355048 git.c:344               trace: built-in: git 'fetch' '--update-head-ok'
18:16:13.361063 run-command.c:626       trace: run_command: 'C:\ProgramData\chocolatey\bin\PLINK.EXE' 'git@xxxxxxx' 'git-upload-pack '\''xxxxxxx/master.git'\'''
18:16:19.820957 run-command.c:626       trace: run_command: 'rev-list' '--objects' '--stdin' '--not' '--all' '--quiet'
18:16:19.882937 run-command.c:626       trace: run_command: 'rev-list' '--objects' '--stdin' '--not' '--all' '--quiet'
18:16:19.897933 git.c:344               trace: built-in: git 'rev-list' '--objects' '--stdin' '--not' '--all' '--quiet'
18:16:19.976095 run-command.c:1452      run_processes_parallel: preparing to run up to 1 tasks
18:16:19.976095 run-command.c:1484      run_processes_parallel: done
18:16:19.976095 run-command.c:626       trace: run_command: 'gc' '--auto'
18:16:19.988095 git.c:344               trace: built-in: git 'gc' '--auto'
18:16:19.999065 run-command.c:626       trace: run_command: 'merge' 'FETCH_HEAD'
18:16:20.013068 git.c:344               trace: built-in: git 'merge' 'FETCH_HEAD'
error: unable to create file test/template/PRN.template: No such file or directory
Updating c23fc916..6dd18de8

(顺便说一句,这在Windows版Git,TortoiseGit上以及尝试通过IntelliJ克隆时均失败)

但是,如果我启动WSL / Ubuntu并将其检出到我的主目录(因此在我的NTFS分区中),则可以正常工作:

 2018-01-17 19:49:25   DESKTOP-GPVE514 in /mnt/c/Users/mcrow/Programming
○ → git clone --branch master git@xxxxxxxxx/master.git
Cloning into 'master'...
remote: Counting objects: 24462, done.
remote: Compressing objects: 100% (108/108), done.
remote: Total 24462 (delta 115), reused 87 (delta 68)
Receiving objects: 100% (24462/24462), 277.43 MiB | 840.00 KiB/s, done.
Resolving deltas: 100% (17596/17596), done.
Checking connectivity... done.
Checking out files: 100% (2521/2521), done.

尽我所能,这对于Windows编写文件的Git肯定是有用的,但是我不知道是什么。

这是更多信息:通过WSL / Ubuntu签出后,我转到该目录并做了一个git status这表明:

→ git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add/rm <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        deleted:    test/template/PRN.template

no changes added to commit (use "git add" and/or "git commit -a")

但是,该文件在那里:

→ ls -1 test/template/
total 14
'Complex Testing Scenario.template'
create_from_template.py
PRN.template
Scheduled.template

但是,从Windows来看,这仍然是一个问题:

→ git reset --hard HEAD
error: unable to create file test/template/PRN.template: No such file or directory
fatal: Could not reset index file to revision 'HEAD'.

如果此方法适用于Ubuntu,但不适用于Windows,请仔细检查路径(父文件夹)或文件本身的大小写(大写/小写)。

Windows将无法检出路径或名称与另一文件相似的文件(大小写不同)。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

git checkout-<文件名>无法恢复Windows 10上本地删除的符号链接

Windows 10 上 git-bash shell“MINGW64”的 CLI 中的“bash:export:...不是有效标识符”

在代码块Windows 10中的代码中安装MinGW-x64,错误:找不到这样的文件或目录

“ git无法读取当前工作目录,没有错误”-豪华git(Windows 10)

Windows 10 Pro中的Docker:python:无法打开文件'manage.py':[Errno 2]无此文件或目录

Git错误:无法执行git log && git diff [无此文件或目录]

更改Git-Bash中的目录:在Windows计算机上的MINGW64中使用Windows风格的目录地址

在 Windows 10 中安装 git

Windows 10上的Git麻烦

Windows 10中〜/ .git-credentials文件的位置?

Bazel,带有mingw64编译器的Windows 10工具链配置

如何在Windows 10上为代码块17.02指定MinGW64?

如何在 Windows 10 上为代码块 17.02 指定 MinGW64?

在Windows 10上安装MinGW64是否存在任何风险?

Python getpass在Windows Git Bash(MINGW64)上不起作用

如何在 Windows 上的 git bash (MINGW64) 中停止滚动输出?

git checkout所有文件

git checkout不重置文件

git checkout 文件已过时

创建别名Git Bash Windows 10

Git Checkout分支不会更改工作目录

在Windows 10中发送git命令时出现“致命:身份验证失败”错误

尝试在 Windows 10 上签署 git 提交时 gpg 跳过 KEY No secret key 错误消息

NODEMCU DOCKER marcelstoer/docker-nodemcu-build “Not a git repository” WINDOWS 10 中的致命错误

如何在Windows 10上使用git更改相同格式的多个文件名?

无法删除所有带有“ git rm -r -f {folder_name}”的文件(Windows 10)

Git Checkout [Tab]显示了很多分支

Jenkins Groovy管道-git checkout错误

git checkout发生错误。路径太长