我检查了我的存储库但是文件名太长了文件:
~/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。
任何人都可以帮我查看长文件吗?
答案 0 :(得分:18)
答案 1 :(得分:9)
如果您使用的是ubuntu的加密主目录功能,请尝试查看不在您家中的目录; ecryptfs可能导致文件名在底层文件系统上变得更长。否则,您可以使用以下过程获取数据:
首先,导航到包含目录,然后键入git ls-files --stage
。你应该看到以下形式的一堆输出:
100644 16890852350cb62bb9f9aec5e52eea8ba46f1192 0 somefile
找到与您感兴趣的文件相对应的哈希值。现在做:
git cat-file blob 16890852350cb62bb9f9aec5e52eea8ba46f1192 > shortername.pdf
其中,shortname.pdf是相关文件的新名称,将散列替换为您在上面找到的散列。这将提取相关文件的内容。
现在就做:
git add shortername.pdf
git rm --cached $VERYLONGNAME.pdf
git commit
这将有效地将过长的PDF重命名为更合理的名称。