How to Fix “Filename too long” Errors in Git on Windows and Linux

Photo by Yancy Min on Unsplash

When working with Git repositories, you may encounter the “filename too long” error during clone operations. This error occurs due to path length limitations in different operating systems. This guide will show you how to resolve this issue on both Windows and Linux systems.

By following this guide, you’ll be able to successfully clone repositories that contain long filenames and continue with your development work.

Prerequisites

  • Git installed on your system
  • Administrator/root access to modify system configurations
  • Basic command line knowledge
  • A Git repository to clone

Identifying the Problem

The error typically appears in one of these forms:

error: unable to create file <long_path>: Filename too long

error: invalid path ‘<long_path>’

Solution for Windows

Method 1: Enable Long Paths in Windows and Git

  1. Enable long path support in Windows by running PowerShell as Administrator and executing:
PS> New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem"…

Leave a Reply