Git cannot read or access the .git/info/exclude file, which stores local ignore patterns. This typically occurs due to missing file, incorrect permissions, or filesystem issues.
The .git/info/exclude file is a special Git configuration file that stores ignore patterns specific to your local repository. Unlike .gitignore files which are tracked and shared with other developers, the exclude file is local-only and lives inside the .git directory. When Git encounters an error accessing this file, it means either the file doesn't exist, has incorrect permissions, or there's a filesystem-level problem preventing access. This error commonly appears as a warning during git status, git add, or other commands that need to check which files should be ignored. While Git can usually continue operating even with this warning, it may cause unexpected behavior with file tracking if you were relying on patterns in the exclude file. The .git/info/exclude file serves the same purpose as .gitignore but is never committed to the repository. It's useful for ignoring files that are specific to your local development environment, such as editor configurations, temporary files, or personal debugging scripts that other collaborators don't need to ignore.
First, check if the info directory exists within your .git folder:
ls -la .git/infoIf the directory doesn't exist, create it:
mkdir -p .git/infoIf the exclude file doesn't exist, create it as an empty file or with your desired patterns:
touch .git/info/excludeAlternatively, create it with an editor:
nano .git/info/excludeThe file can be empty or contain patterns just like .gitignore. Each pattern should be on a new line.
Check the current permissions of the exclude file:
ls -l .git/info/excludeEnsure the file is readable by your user. Fix permissions if needed:
chmod 644 .git/info/excludeIf the entire .git/info directory has permission issues:
chmod 755 .git/infoVerify that .git/info/exclude is a file and not a directory:
file .git/info/excludeIf it's a directory by mistake, remove it and create the correct file:
rm -rf .git/info/exclude
touch .git/info/excludeCheck if you have a conflicting excludesfile configuration:
git config --get core.excludesfileIf this points to an incorrect location or a directory instead of a file, remove or fix it:
git config --unset core.excludesfileOr update it to point to the correct global exclude file (usually in your home directory):
git config --global core.excludesfile ~/.gitignore_globalAfter fixing the issue, verify that Git can now read the exclude file:
git check-ignore -v some-fileThis will show which ignore file (if any) is causing a file to be ignored, confirming that .git/info/exclude is being read correctly.
For Git for Windows users experiencing this error on network drives or with the fscache feature, consider upgrading to Git version 2.21.0 or later, which fixed a known bug. You can also disable fscache as a workaround: git config core.fscache false
If you're encountering line ending issues (particularly on Windows/MSYS2), convert the file to Unix format: dos2unix .git/info/exclude
Remember that the .git/info/exclude file only affects untracked files. If a file is already being tracked by Git, adding it to the exclude file won't stop Git from tracking it. You'll need to use git rm --cached to untrack it first.
For system administrators dealing with SELinux or AppArmor, you may need to adjust security policies to allow Git to access files within the .git directory. Check audit logs for specific policy violations.
The .git/info/exclude file uses the same pattern syntax as .gitignore: wildcards (*), directory indicators (/), negation (!), and comments (#). Patterns are relative to the repository root.
warning: BOM detected in file, this may cause issues
UTF-8 Byte Order Mark (BOM) detected in file
fatal: Server does not support --shallow-exclude
Server does not support --shallow-exclude
warning: filtering out blobs larger than limit
Git partial clone filtering large blobs warning
fatal: Server does not support --shallow-since
Server does not support --shallow-since in Git
kex_exchange_identification: Connection closed by remote host
Connection closed by remote host when connecting to Git server