Git Clone Fails in Jenkins with “Filename Too Long” Error – Fix


Recently, we started facing an issue in our automation jobs where builds were failing in Jenkins while cloning the Git repository.

The error we observed was:

error: unable to create file
src/......../path/to/that/file/abc.java is too long




Root Cause

After investigating the issue, we found that the root cause was a limitation in Windows.

By default, Windows has a maximum file path length limit of 260 characters.
If the repository contains deeply nested folders or long file names, Git fails to create those files during the clone operation.


Solution

To resolve this issue, we need to enable long path support in Git.

Steps to Fix

  1. Open Git Bash on the affected machine with administrator privileges
  2. Run the following command:

Once this command is executed successfully, the issue gets resolved and Git is able to clone repositories with long file paths.


Key Takeaways

  • Windows has a default file path limit of 260 characters
  • Git cloning may fail for deeply nested repositories
  • Enabling core.longpaths resolves the issue

Final Note

This is a common issue in CI/CD environments like Jenkins when working with large repositories.
It’s a simple fix, but not very obvious if you’re not aware of the Windows limitation.

Post a Comment

0 Comments