c++ - git 和 libgit : unable to create file (No such file or directory)

标签 c++ git

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

但是它们似乎仍然存在于 repo 中。这就是我尝试查看存储库时得到的结果。

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 目录,checkout -f 会起作用。

更奇怪的是,整个事情在 MacOSx 下按原样运行,但在 Windows 下却不行......

知道这里发生了什么吗?

最佳答案

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

看到报价了吗? git 将使用 C 字符串文字约定来显示其中包含不寻常字符的文件名。您的存储库记录了一个以该 C 字符串作为名称的文件——包括反斜杠。

:\/ 并不是到处都是无效的,

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

但它们不可移植。

大致来说,Windows文件系统保留\:,Mac,:,Unix,/。可能仍有系统保留;

关于c++ - git 和 libgit : unable to create file (No such file or directory),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19588879/

相关文章:

c++ - "warning: integer overflow in expression"

git - 当 git merge 冲突文件包含字符串 "======="时会发生什么

c++ - 是否有可用于 C++ 的广泛使用的多处理抽象库?

c++ - 用于存储指针的线程安全循环缓冲区

c++ - 设置 GL_TEXTURE_MAX_ANISOTROPY_EXT 会导致下一帧崩溃

git - 在 git 中编写长提交消息?

ruby-on-rails - 在 Heroku 的远程存储库之间切换

xcode - Git merge 二进制文件(特别是 Xcode 项目文件)

git - Teamcity REST API 在分支上获得最新的成功构建

c++ - 塞类模拟键盘输入