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

前端 未结 2 662
日久生厌
日久生厌 2020-12-09 17:54

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         


        
相关标签:
2条回答
  • 2020-12-09 18:33

    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

    0 讨论(0)
  • 2020-12-09 18:55

    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 讨论(0)
提交回复
热议问题