Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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. My file system is ext4 on Ubuntu 10.10.

Can anyone help me to check out the long file?

like image 802
Strubbl Avatar asked May 24 '11 17:05

Strubbl


2 Answers

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

like image 54
manojlds Avatar answered Oct 18 '22 21:10

manojlds


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.

like image 29
bdonlan Avatar answered Oct 18 '22 23:10

bdonlan