DEV Community

Cover image for Fixing Git "Out of Diskspace" Error When You Actually Have Space The Misleading Error
Alin Ciovica
Alin Ciovica

Posted on

Fixing Git "Out of Diskspace" Error When You Actually Have Space The Misleading Error

I recently encountered a frustrating Git issue that had me scratching my head. While working on a rebase operation, Git kept throwing this error:

fatal: sha1 file '.git/index.lock' write error. Out of diskspace

The confusing part? I had over 48GB of free space on my drive. This clearly wasn't a disk space issue, despite what the error message claimed.

The Real Problem: Windows Path Length Limits

After some investigation, I discovered the real culprit: Windows has a default path length limit of 260 characters. When Git tried to create files with long paths (especially in deeply nested directory structures with lengthy filenames), Windows would block the operation. Git would then misinterpret this as a disk space error.

This is particularly common in projects with:

  • Deep folder hierarchies
  • Long library names
  • Nested files and documentation

The Solution That Worked

# Enable long paths in Git globally
git config --global core.longpaths true
# Enable long paths for the current repository
git config core.longpaths true
# Clean up any corrupted or incomplete files
git clean -fdx
# Run garbage collection to clean up the repository
git gc
Enter fullscreen mode Exit fullscreen mode

What These Commands Do

core.longpaths true: Tells Git to use Windows long path support (up to 32,767 characters)
git clean -fdx: Removes all untracked files and directories, including ignored files
git gc: Runs garbage collection to optimize the repository and remove unnecessary files

Key Takeaway

Don't trust Git's "Out of diskspace" error at face value. If you have plenty of free disk space, the issue is likely:

  • Windows path length limitations
  • File system permissions
  • Corrupted Git index files

Enabling core.longpaths should be one of your first troubleshooting steps on Windows, especially when working with large projects or repositories with deep directory structures.

System Requirements

Note that long path support requires:

Windows 10 version 1607 or later
The appropriate registry settings (usually enabled by default on modern Windows)
After applying this fix, my rebase operation completed successfully without any further issues!

Top comments (0)