git pull aborted with error filename too long

I'm using Windows as my OS, and working on a project with a friend who's using a Mac. He checked in code to our Github.

I was trying to git pull everything he did and it aborted with "filename too long" errors of 3rd party code.

What can I do?


The msysgit FAQ on Git cannot create a filedirectory with a long path seems not up to date, as it still links to old msysgit ticket #110. However, according to later ticket #122 the problem has been fixed in msysgit 1.9, thus:

  • Update to msysgit 1.9 (or later)
  • Launch Git Bash
  • Got to your Git repository which 'suffers' of long paths issue
  • Enable long paths support with git config core.longpaths true
  • So far, it's worked for me very well.

    Be aware of important notice in comment on the ticket #122

    don't come back here and complain that it breaks Windows Explorer, cmd.exe, bash or whatever tools you're using.


    Solution1 - set global config, by running this command:

    git config --system core.longpaths true
    

    Solution2 - or you can edit directly your specific git config file like below:

    YourRepoFolder -> .git -> config:

    [core]
        repositoryformatversion = 0
        filemode = false
        ...
        longpaths = true        <-- (add this line under core section)
    

    Solution3 - when cloning a new repository: here.


    A few years late, but I'd like to add that if you need to do this in one fell swoop (like I did) you can set the config settings during the clone command. Try this:

    git clone -c core.longpaths=true <your.url.here>

    链接地址: http://www.djcxy.com/p/41700.html

    上一篇: 子文件导入和多个分支目录

    下一篇: 错误文件名太长,git pull中止