简体   繁体   English

git checkout-index:无法创建文件(文件名太长)

[英]git checkout-index: unable to create file (File name too long)

I check out my repository but there is a file with too long file name:我检查了我的存储库,但有一个文件名太长的文件:

~/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 is about 160 chars long. $VERYLONGNAME 大约 160 个字符长。 My file system is ext4 on Ubuntu 10.10.我的文件系统是 Ubuntu 10.10 上的 ext4。

Can anyone help me to check out the long file?谁能帮我检查一下长文件?

You might need to disable home directory encryption or checkout outside like /tmp您可能需要禁用主目录加密或在/tmp等外部签出

I think it limits the filename size to 144 characters.我认为它将文件名大小限制为 144 个字符。

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

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

If you are using ubuntu's encrypted home directory feature, try checking out to a directory not under your home;如果您使用的是 ubuntu 的加密主目录功能,请尝试检出到不在您的主目录下的目录; ecryptfs can result in filenames becoming longer on the underlying filesystem. ecryptfs 可能导致文件名在底层文件系统上变得更长。 Otherwise, you can get the data with the following procedure:否则,您可以通过以下过程获取数据:

First, navigate to the containing directory, and type git ls-files --stage .首先,导航到包含目录,然后输入git ls-files --stage You should see a bunch of output of the following form:你应该看到一堆 output 的形式如下:

100644 16890852350cb62bb9f9aec5e52eea8ba46f1192 0       somefile

Find the hash corresponding to your file of interest.找到与您感兴趣的文件相对应的 hash。 Now do:现在做:

git cat-file blob 16890852350cb62bb9f9aec5e52eea8ba46f1192 > shortername.pdf

Where shortername.pdf is a new name for the file in question, replacing the hash with the one you found above.其中,shortername.pdf 是相关文件的新名称,将 hash 替换为您在上面找到的名称。 This will extract the content of the file in question.这将提取相关文件的内容。

Now just do:现在只需执行以下操作:

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

This will effectively rename the overly-long PDF to a more reasonable name.这将有效地将过长的 PDF 重命名为更合理的名称。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM