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.
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.
First, verify your disk isn't failing and check for filesystem errors. Open Command Prompt as Administrator:
:: 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:
# Check S.M.A.R.T. status in PowerShell
Get-PhysicalDisk | Select-Object FriendlyName, MediaType, HealthStatus
# Or use wmic
wmic diskdrive get statusIf the disk shows "Warning" or "Unhealthy" status, back up your data immediately and replace the drive.
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):
:: 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.
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:
C:\Users\YourName\Projects
C:\Program Files\Git
%USERPROFILE%\.gitconfigFor Windows Defender, add folder exclusions in Windows Security > Virus & threat protection > Manage settings > Exclusions.
Verify you have adequate free space. Git needs space to create temporary files and object files:
# 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:
fsutil quota query C:If the repository has accumulated corrupt or incomplete objects, clean it up:
# 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 -fIf git fsck reports corrupted objects, you may need to fetch fresh copies:
# 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 --allIf your repository is on a network drive (mapped drive, UNC path, or cloud-synced folder), move it to a local drive:
:: 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:5Avoid 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.
If you dual-boot Windows with Linux, Windows Fast Startup can leave NTFS in a hibernated state, causing write errors when accessed from Linux:
:: Disable Fast Startup via Command Prompt (as Administrator)
powercfg /hibernate offOr 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.
If the repository remains corrupted after other fixes, clone a fresh copy:
# 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.patchIf you have committed changes that haven't been pushed:
# 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-branchDelete the old corrupted repository only after verifying the fresh clone works correctly.
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:
git config --global core.createObject linkThis 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
fatal: bad object in rev-list input
Git rev-list encounters bad or invalid object
fatal: Out of memory, malloc failed during pack operation
Out of memory during Git pack operation
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server
fatal: unable to access: Proxy auto-configuration failed
How to fix 'Proxy auto-configuration failed' in Git
fatal: unable to access: Authentication failed (proxy requires basic auth)
How to fix 'Authentication failed (proxy requires basic auth)' in Git