开发者

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 (d开发者_StackOverflow中文版elta 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. My file system is ext4 on Ubuntu 10.10.

Can anyone help me to check out the long file?


You might need to disable home directory encryption or checkout outside like /tmp

I think it limits the filename size to 144 characters.

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

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; ecryptfs can result in filenames becoming longer on the underlying filesystem. Otherwise, you can get the data with the following procedure:

First, navigate to the containing directory, and type git ls-files --stage. You should see a bunch of output of the following form:

100644 16890852350cb62bb9f9aec5e52eea8ba46f1192 0       somefile

Find the hash corresponding to your file of interest. 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. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜