git checkout(Windows 10 / mingw64)错误“没有这样的文件或目录”

时间:2018-01-18 03:30:59

标签: windows git

尝试使用在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

(顺便说一下,这对于Git for Windows,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.

我能想到的最好,这绝对是Git for Windows编写文件的东西,但我无法弄清楚是什么。

以下是更多信息:通过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'.

1 个答案:

答案 0 :(得分:1)

如果这在Ubuntu上工作,但在Windows上没有,请仔细检查路径(父文件夹)或文件本身的大小写(upercase / lowercase)。

Windows无法使用与其他路径或名称相似的路径或名称签出文件,但案例不同。