Git refuses to merge because local files have uncommitted changes that would be overwritten. This typically occurs during pull, merge, or checkout operations when your working directory contains modifications that conflict with incoming changes.
This error occurs when Git detects that one or more files in your working directory have been modified but not committed, and those same files would be overwritten or affected by the merge operation you're attempting. Git is protective of your local work and will not proceed with any operation that could potentially destroy uncommitted changes. The "not uptodate" message specifically indicates that the file in your working tree differs from what Git has recorded in its index (staging area), meaning there are pending changes that haven't been staged or committed. This error commonly appears during `git pull`, `git merge`, `git checkout`, or `git rebase` operations when Git needs to modify files that you've already changed locally.
First, identify what files Git considers changed:
git status
git diffThis will show you which files have uncommitted changes. If git status shows changes but git diff shows nothing, the issue is likely related to file metadata or index corruption.
The safest approach is to temporarily save your changes using git stash:
git stash
git pull
git stash popThis saves your local modifications, performs the merge, and then reapplies your changes. If there are conflicts after git stash pop, you'll need to resolve them manually.
If you've used git add -N (intent-to-add), you need to fully stage those files:
# Check for intent-to-add files
git status
# Fully stage the files
git add <filename>
# Or stage all pending files
git add .After staging, you can either commit these changes or use git stash to temporarily save them.
If you don't need your local changes, you can restore the file to match the repository:
# Using git restore (Git 2.23+)
git restore <filename>
# Or using the older checkout command
git checkout -- <filename>Warning: This will discard any uncommitted changes to that file.
If the error persists despite no visible changes, refresh the Git index:
# Refresh the index
git update-index --refresh
# Or force a hard reset (WARNING: discards all uncommitted changes)
git reset --hard HEADThe hard reset should only be used if you've backed up any important changes.
Files with special flags can cause this error. Check and remove these flags:
# List files with assume-unchanged
git ls-files -v | grep '^[a-z]'
# List files with skip-worktree
git ls-files -v | grep '^S'
# Remove assume-unchanged flag
git update-index --no-assume-unchanged <filename>
# Remove skip-worktree flag
git update-index --no-skip-worktree <filename>If backup software or file indexers are modifying file metadata:
git config core.trustctime falseThis tells Git to ignore the ctime (inode change time) when determining if files have changed.
### Understanding Git's Index
The "not uptodate" error specifically relates to Git's index (staging area). Git maintains three trees: the working directory, the index, and the HEAD commit. When any of these fall out of sync in unexpected ways, this error can occur.
### Case Sensitivity Issues
On case-insensitive file systems (Windows NTFS, macOS HFS+ by default), Git can track files like File.txt and file.txt as separate entries, but the filesystem sees them as one file. This causes persistent "not uptodate" errors. To resolve:
# Check for case conflicts
git ls-files | sort -f | uniq -di
# Fix by removing one variant
git rm --cached <conflicting-filename>### Repository Synchronization Issues
When copying repositories between systems (via rsync, cloud sync, or manual copying), file inodes change but content remains identical. Git may detect these as modifications. Running git status followed by git checkout -- . or git reset --hard usually resolves this.
### Force Checkout as Last Resort
If all else fails, you can force a checkout:
git checkout -f HEADThis forces Git to overwrite working tree files, but use with caution as it discards local changes.
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
fatal: unable to access: no_proxy configuration not working
How to fix 'no_proxy configuration not working' in Git
fatal: unable to read tree object in treeless clone
How to fix 'unable to read tree object in treeless clone' in Git