How to fix error: unable to write sha1 filename: Input/output error in Git

GitINTERMEDIATEHIGHUpdated Dec 6, 2025ยท 179 views

This error occurs when Git cannot write object files to the .git/objects directory due to filesystem issues, disk problems, or NTFS-specific limitations on Windows. The fix involves checking disk health, disabling NTFS compression, and ensuring proper filesystem access.

Quick fix

Fixes error: unable to write sha1 filename: Input/output error

:: Check disk for errors (replace C: with your drive letter)
chkdsk C: /f /r

:: For a quick check without repair
chkdsk C:
  1. Check disk health and run chkdsk
  2. Disable NTFS compression on the repository folder
  3. Temporarily disable antivirus real-time scanning
  4. Check and free up disk space
git โ€” error
:: Check disk for errors (replace C: with your drive letter)
chkdsk C: /f /r
:: For a quick check without repair
chkdsk C:
error: unable to write sha1 filename: Input/output error

What this error means

The "unable to write sha1 filename: Input/output error" message in Git indicates that Git is unable to write an object file to its internal database located in the `.git/objects` directory. Git stores all repository data (commits, files, trees) as compressed objects named by their SHA-1 hash. When Git attempts to create or update these object files and the operating system returns an I/O error, it means there's a problem at the filesystem or hardware level rather than with Git itself. On Windows with NTFS, this error often stems from NTFS compression conflicts, disk corruption, antivirus interference, or network drive issues. The "Input/output error" (also known as EIO) is a low-level error that the filesystem returns to Git, indicating the write operation failed. This can happen even when disk space appears available and permissions seem correct, because the underlying issue is with how the filesystem handles the write request.

Typical symptoms

  • Git commands fail with 'error: unable to write sha1 filename' followed by 'Input/output error'
  • git add, git commit, or git fetch operations fail unexpectedly
  • Error appears intermittently, sometimes working after retrying
  • Problem occurs more frequently with large files or many files
  • Git operations work on some repositories but not others on the same drive
  • Windows Event Viewer shows disk or filesystem warnings

Common causes

  1. NTFS compression enabled on the repository folder causing write conflicts
  2. Disk corruption or bad sectors on the storage device
  3. Antivirus software scanning and locking Git object files during write
  4. Repository located on a network drive with connectivity or permission issues
  5. Disk quota exceeded on the drive or user account
  6. External USB drive with unstable connection or being ejected during operations
  7. Windows Fast Hibernation ('hiberboot') causing NTFS inconsistencies when dual-booting
  8. Failing hard drive or SSD with degraded performance

How to fix "error: unable to write sha1 filename: Input/output error"

1Check disk health and run chkdsk

First, verify your disk isn't failing and check for filesystem errors. Open Command Prompt as Administrator:

cmd
:: Check disk for errors (replace C: with your drive letter)
chkdsk C: /f /r

:: For a quick check without repair
chkdsk C:

If errors are found, Windows will schedule a disk check on the next restart. You can also check disk health using:

powershell
# Check S.M.A.R.T. status in PowerShell
Get-PhysicalDisk | Select-Object FriendlyName, MediaType, HealthStatus

# Or use wmic
wmic diskdrive get status

If the disk shows "Warning" or "Unhealthy" status, back up your data immediately and replace the drive.

2Disable NTFS compression on the repository folder

NTFS compression can interfere with Git's object file creation. Disable it on your repository folder:

Using File Explorer:
1. Right-click on your repository folder
2. Select "Properties"
3. Click "Advanced..."
4. Uncheck "Compress contents to save disk space"
5. Click OK and apply to all subfolders and files

Using Command Prompt (as Administrator):

cmd
:: Navigate to the parent directory of your repo
cd C:\Users\YourName\Projects

:: Remove compression from the repository folder
compact /u /s /a /i "your-repo"

After disabling compression, try your Git operation again.

3Temporarily disable antivirus real-time scanning

Antivirus software often scans files as they're created, which can conflict with Git's rapid object file creation. Temporarily disable real-time protection:

Windows Defender:
1. Open Windows Security
2. Go to "Virus & threat protection"
3. Click "Manage settings" under "Virus & threat protection settings"
4. Toggle off "Real-time protection"
5. Run your Git command
6. Re-enable real-time protection immediately after

Better long-term solution: Add exclusions for Git directories:

bash
C:\Users\YourName\Projects
C:\Program Files\Git
%USERPROFILE%\.gitconfig

For Windows Defender, add folder exclusions in Windows Security > Virus & threat protection > Manage settings > Exclusions.

4Check and free up disk space

Verify you have adequate free space. Git needs space to create temporary files and object files:

powershell
# Check available space
Get-PSDrive C | Select-Object Used, Free

# Or in Command Prompt
fsutil volume diskfree C:

If space is low, clean up:
- Run Disk Cleanup (cleanmgr.exe)
- Clear npm cache: npm cache clean --force
- Remove unused Docker images: docker system prune -a
- Delete old Git branches: git remote prune origin

Also check for disk quotas if you're on a corporate machine:

cmd
fsutil quota query C:
5Run Git garbage collection and repair

If the repository has accumulated corrupt or incomplete objects, clean it up:

bash
# Verify repository integrity
git fsck --full

# Remove loose objects and pack repository
git gc --prune=now

# Aggressive cleanup (use with caution)
git gc --aggressive --prune=now

# Repack all objects
git repack -a -d -f

If git fsck reports corrupted objects, you may need to fetch fresh copies:

bash
# Remove any corrupt loose objects (empty files)
# PowerShell command to find empty files in .git/objects:
Get-ChildItem -Path .git/objects -Recurse -File | Where-Object { $_.Length -eq 0 } | Remove-Item

# Then fetch from remote
git fetch --all
6Move repository off network drive

If your repository is on a network drive (mapped drive, UNC path, or cloud-synced folder), move it to a local drive:

cmd
:: Copy repository to local drive
xcopy /E /H /K "\\server\share\repo" "C:\Projects\repo\"

:: Or using robocopy for better reliability
robocopy "Z:\repo" "C:\Projects\repo" /E /COPYALL /R:3 /W:5

Avoid these locations for Git repositories:
- OneDrive, Google Drive, or Dropbox synced folders
- Network mapped drives
- External USB drives (unless stable)

After moving, update any IDE workspace settings to point to the new location.

7Disable Windows Fast Startup (if dual-booting)

If you dual-boot Windows with Linux, Windows Fast Startup can leave NTFS in a hibernated state, causing write errors when accessed from Linux:

cmd
:: Disable Fast Startup via Command Prompt (as Administrator)
powercfg /hibernate off

Or via Control Panel:
1. Open Control Panel > Power Options
2. Click "Choose what the power buttons do"
3. Click "Change settings that are currently unavailable"
4. Uncheck "Turn on fast startup"
5. Save changes

After disabling, fully shut down Windows (not restart) before accessing the drive from Linux.

8Clone fresh as a last resort

If the repository remains corrupted after other fixes, clone a fresh copy:

bash
# Back up any uncommitted changes
git stash
git stash show -p > my-changes.patch

# Clone fresh to a new directory
cd ..
git clone <remote-url> repo-fresh

# Apply your changes to the fresh clone
cd repo-fresh
git apply ../repo/my-changes.patch

If you have committed changes that haven't been pushed:

bash
# In the old repo, create a bundle of unpushed commits
git bundle create ../unpushed.bundle origin/main..HEAD

# In the fresh clone, apply the bundle
git fetch ../unpushed.bundle main:temp-branch
git merge temp-branch

Delete the old corrupted repository only after verifying the fresh clone works correctly.

Advanced notes

Understanding the error at the OS level: The "Input/output error" (EIO) is returned by the Windows kernel when a write operation fails at the filesystem or disk level. This is distinct from permission errors (EACCES) or disk full errors (ENOSPC). EIO typically indicates hardware problems, driver issues, or filesystem corruption.

NTFS compression internals: When NTFS compression is enabled, Windows compresses files in 64KB chunks. Git's rapid creation of many small object files can overwhelm this process, especially during operations that create thousands of loose objects. The compression algorithm may also conflict with Git's zlib-compressed object format, causing write failures.

Diagnosing with Windows Event Viewer: Check for disk errors in Event Viewer:
1. Open Event Viewer (eventvwr.msc)
2. Navigate to Windows Logs > System
3. Filter by Source: disk, ntfs, storahci
4. Look for Error or Warning events around the time of the Git failure

Common indicators of failing disks include events like "The device has a bad block" or "Reset to device was issued."

Git for Windows core.createobject setting: For network drives and Samba shares, Git for Windows has a configuration option that can help:

bash
git config --global core.createObject link

This changes how Git creates object files, using hardlinks instead of renames, which works better on some network filesystems.

WSL considerations: If you're accessing Windows files from WSL (Windows Subsystem for Linux), ensure you're using the /mnt/c/ path correctly and that the Windows drive is properly mounted. Running Git from the native Windows Git for Windows may be more reliable than WSL Git when working with NTFS volumes.

Preventing future issues:
- Regularly run git gc to keep the repository clean
- Monitor disk health with tools like CrystalDiskInfo
- Keep repositories on local SSDs when possible
- Exclude Git folders from antivirus real-time scanning
- Avoid storing repositories in cloud-synced folders

Frequently asked questions

What does "error: unable to write sha1 filename: Input/output error" mean?
git/objects directory. Git stores all repository data (commits, files, trees) as compressed objects named by their SHA-1 hash. When Git attempts to create or update these object files and the operating system returns an I/O error, it means there's a problem at the filesystem or hardware level rather than with Git itself.
How do I fix "error: unable to write sha1 filename: Input/output error"?
This error occurs when Git cannot write object files to the .git/objects directory due to filesystem issues, disk problems, or NTFS-specific limitations on Windows. The fix involves checking disk health, disabling NTFS compression, and ensuring proper filesystem access.
What causes "error: unable to write sha1 filename: Input/output error"?
NTFS compression enabled on the repository folder causing write conflicts Disk corruption or bad sectors on the storage device Antivirus software scanning and locking Git object files during write
Is the "error: unable to write sha1 filename: Input/output error" error serious?
Yes. This is a high-severity error that usually blocks work until it is fixed, but the steps above resolve it.

Official resources & further reading