0

I did a commit (with Git) & push (to GitHub) 2 pdf files with a bit long names on my Windows 7 machine and then tried to pull those onto my Linux Mint machine, but got this error:

Updating 1453916..ffdfabc
error: cannot stat 'long-file-name-1.pdf': File name too long
error: cannot stat 'long-file-name-2.pdf': File name too long

How can I have those 2 files on my Linux Machine without losing the names and/or the files?

Alaz Tetik
  • 39
  • 1
  • 7
  • That's rather strange. I expected git on Linux handles very long file names better than git-for-windows. – phd Dec 01 '19 at 22:49
  • 1
    BTW, do you use [encrypted home](https://stackoverflow.com/a/6114588/7976758)? And the repository is somewhere below `$HOME`? – phd Dec 01 '19 at 22:52
  • What is the length of these names? – root Dec 01 '19 at 23:02
  • @phd, yes I use encrypted home on my Linux Mint and the repo is in a dir below home. The file name was: "Critical parameters in designing segmented polyurethanes and their effect on morphology and properties- A comprehensive review, Yılgör, 2014.pdf" including 140 chars and 2 of them as non-ASCII Unicode chars: "ı" and "ö". – Alaz Tetik Dec 06 '19 at 06:13

1 Answers1

0

If you're NOT using encrypted home, as suggested by @phd, then you're most likely encountering a limitation of Linux that does not exist in Git.

Most Linux kernels are compiled with NAME_MAX=255 (see here). Which means that file names cannot take more than 255 bytes. If you're using non-ASCII Unicode characters, than you have even less than 255 characters.

In Windows the limit is bigger than 255 bytes, which is why you're able to create these files in Windows.

If you want it to work on Linux, you need to rename them in Windows to something that is 255 bytes (bytes, not characters!) or less.

If you intend to check out those revisions, you'll need to do some history rewrite.

There are much crazier alternatives like re-compiling the kernel with a different NAME_MAX, don't go there if you don't absolutely have to.

root
  • 5,528
  • 1
  • 7
  • 15