Search code examples
windowsgitfilenameslong-filenames

Filename too long in Git for Windows when git clone is aborted in the middle


I have a problem similar to this question BUT this is not a duplicate since the problem is different.

In that question, there was the problem of filenames too long for windows. The answer provided was to apply git config core.longpaths true

My own personal problem is that I have started cloning a repository. *In the middle of * clonning it stopped due to the filename too large error.

I tried

git config --system core.longpaths true

error: could not lock config file C:/Program Files/Git/etc/gitconfig: Permission denied

In the answer it says that it is better to not apply this globally so I did

git config core.longpaths true
fatal: not in a git directory

Ok I cd into the folder with the repo and I did the above and no problem. It is set. But an interrupted clone can not be continued so if I erase the folder the config set would dissapear too right?

So how can I do the git clonning without this problem?


Solution

  • Set it temporarily with --global, and then unset it when the repo is cloned, and then set it locally to the repo?

    You can also initialize an empty repository, set the thing locally, add a remote and finally fetch that remote, something like:

    $ mkdir my_repo
    $ cd my_repo
    $ git init
    $ git config core.longpaths true
    $ git remote add origin https://github.com/repo/whatever.git
    $ git fetch origin