git和libgit:无法创建文件(没有这样的文件或目录)

时间:2013-10-25 11:42:16

标签: c++ git

我正在使用libgit2创建一个git存储库和一个提交(在C ++中)。 它运行正常,但是,结帐会破坏所有本地文件。

然而,它们似乎仍然存在于回购中。当我试图查看存储库时,这就是我得到的。

Welcome to Git (version 1.8.3-preview20130601)


Run 'git help git' to display the help index.
Run 'git help <command>' to display help for specific commands.

x@x-PC /C/Users/x/Desktop/poiu (master)
$ git log
commit a63cd37ef7d7228053b875e396531d367e2ea745
Author: Unregistered User <unregistered@x.com>
Date:   Fri Oct 25 13:27:21 2013 +0200

    Project Save

x@x-PC /C/Users/x/Desktop/poiu (master)
$ git checkout a63cd37ef7d7228053b875e396531d367e2ea745
D       "db\\32\\879a83081b8d0b4ef41a37b9e28138"
D       "db\\41\\930644af1f4ab6d288bf3d50829558"
D       "db\\48\\3172d42be6ccb80e57071d5aabb584"
D       "db\\80\\0b152a41ba2ef0bc1c55c96add4d33"
D       "db\\c1\\3b1ce3276ed14d7ff7c6ace9b63cf3"
D       "db\\fa\\50e29fe380a8117140463106ae67b1"
Note: checking out 'a63cd37ef7d7228053b875e396531d367e2ea745'.

You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.

If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:

  git checkout -b new_branch_name

HEAD is now at a63cd37... Project Save

x@x-PC /C/Users/x/Desktop/poiu ((a63cd37...))
$ git checkout -f a63cd37ef7d7228053b875e396531d367e2ea745
error: unable to create file db\32\879a83081b8d0b4ef41a37b9e28138 (No such file or directory)
error: unable to create file db\41\930644af1f4ab6d288bf3d50829558 (No such file or directory)
error: unable to create file db\48\3172d42be6ccb80e57071d5aabb584 (No such file or directory)
error: unable to create file db\80\0b152a41ba2ef0bc1c55c96add4d33 (No such file or directory)
error: unable to create file db\c1\3b1ce3276ed14d7ff7c6ace9b63cf3 (No such file or directory)
error: unable to create file db\fa\50e29fe380a8117140463106ae67b1 (No such file or directory)
HEAD is now at a63cd37... Project Save

x@x-PC /C/Users/x/Desktop/poiu ((a63cd37...))
$

现在,什么是“奇怪”的是,如果我手动创建db \ xx目录,结帐-f工作。

即使更奇怪,整个过程在MacOSx下工作,但不是Windows ......

知道这里发生了什么吗?

2 个答案:

答案 0 :(得分:3)

$ git checkout a63cd37ef7d7228053b875e396531d367e2ea745
D       "db\\32\\879a83081b8d0b4ef41a37b9e28138"

看到报价? git将使用C字符串文字约定来显示其中包含异常字符的文件名。您的repo记录一个文件,其中包含该C字符串作为其名称 - 包含反斜杠。

:\/无处不在,

$ touch "db\\32\\879a83081b8d0b4ef41a37b9e28138"
$ ls
db\32\879a83081b8d0b4ef41a37b9e28138
$ git add .
$ git ls-files
"db\\32\\879a83081b8d0b4ef41a37b9e28138"
$ 

但它们不便携。

粗略地说,Windows文件系统保留\:,Mac,:,Unix,/。可能仍有系统保留;

答案 1 :(得分:1)

您可以检查您是否处于MacOSx和Windows处于分离的Head状态吗?

另一个想法是文件系统的差异,也许你可以找到与此相关的东西?