Languages
[Edit]
EN

Git - filename too long error

5 points
Created by:
Tehya-Blanchard
474

In this article, we would like to show how to let git working with long paths.

Quick solution (run it as administrator):

git config --system core.longpaths true

Below you can find the example, when the problem occurred and different ways to set up loner paths for git using different approaches.

 

1. Problem description

When I execute git pull command I get fllowing error:

$ git pull
error: cannot stat 'very/long/path/here.../filename.png': Filename too long
Aborting
Updating 42f6e00..66294e7

2. Problem solution

There are two ways how to fix configuration:

  • with git command,
  • with .gitignore file.

2.1. with git command example

When we want to set up paths we can execute in console following command:

  •  for entire operating system:
git config --system core.longpaths true
  • or only for the current repository:
git config core.longpaths true

2.2. with .gitconfig file example

The solution presented in this section works only with repositories that use the file.

Solution:

  1. go to .gitconfig file (example path for a user in Linux ~/.gitconfig),
  2. create [core] section if it does not exist,
  3. add longpaths = true in the section.

.gitconfig file example:

[core]
longpaths = true

Note: .gitcofig file can be located inside project location or in the user home directory.

Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

Git

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join