【问题标题】:git checkout-index: unable to create file (File name too long)git checkout-index:无法创建文件(文件名太长)
【发布时间】:2011-09-01 03:22:23
【问题描述】:

我检查了我的存储库,但有一个文件名太长:

~/git$ git clone git+ssh://server/git/ma.git
Initialized empty Git repository in ~/git/ma/.git/
remote: Counting objects: 1855, done.
remote: Compressing objects: 100% (1594/1594), done.
remote: Total 1855 (delta 656), reused 1078 (delta 222)
Receiving objects: 100% (1855/1855), 54.14 MiB | 701 KiB/s, done.
Resolving deltas: 100% (656/656), done.
error: git checkout-index: unable to create file four_folder/$VERYLONGNAME.pdf (File name too long)

$VERYLONGNAME 的长度约为 160 个字符。我的文件系统是 Ubuntu 10.10 上的 ext4。

谁能帮我检查一下长文件吗?

【问题讨论】:

  • 文件名有空格吗?

标签: git


【解决方案1】:

如果您使用的是 ubuntu 的加密主目录功能,请尝试检查到不在您的主目录下的目录; ecryptfs 可能导致文件名在底层文件系统上变得更长。否则,您可以通过以下过程获取数据:

首先,导航到包含目录,然后输入git ls-files --stage。你应该看到一堆如下形式的输出:

100644 16890852350cb62bb9f9aec5e52eea8ba46f1192 0       somefile

找到与您感兴趣的文件对应的哈希值。现在做:

git cat-file blob 16890852350cb62bb9f9aec5e52eea8ba46f1192 > shortername.pdf

其中,shortername.pdf 是相关文件的新名称,将哈希替换为您在上面找到的名称。这将提取相关文件的内容。

现在就做:

git add shortername.pdf
git rm --cached $VERYLONGNAME.pdf
git commit

这将有效地将过长的 PDF 重命名为更合理的名称。

【讨论】:

    【解决方案2】:

    您可能需要禁用主目录加密或在外部结帐,例如 /tmp

    我认为它将文件名大小限制为 144 个字符。

    http://ubuntuforums.org/showthread.php?t=1173541

    http://ubuntuforums.org/showthread.php?t=1258294

    【讨论】:

    • 谢谢,我将禁用主目录加密。
    • 在我的情况下,从加密磁盘移动 repo 很有帮助,谢谢
    猜你喜欢
    • 2013-08-26
    • 2017-12-26
    • 2012-06-14
    • 1970-01-01
    • 2012-09-17
    • 1970-01-01
    • 2011-09-27
    • 2014-05-03
    • 1970-01-01
    相关资源
    最近更新 更多