How to fix warning: unable to access '.git/info/exclude': Permission denied in Git
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.
Quick fix
Fixes warning: unable to access '.git/info/exclude': Permission denied
ls -la .git/info- Verify the .git/info directory exists
- Create the exclude file if missing
- Fix file permissions
- Check for directory instead of file
ls -la .git/infowarning: unable to access '.git/info/exclude': Permission denied
What this error means
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.
Typical symptoms
- Warning message "unable to access '.git/info/exclude'" appears during git commands
- Permission denied error when Git tries to read the exclude file
- Git commands complete but show unexpected warnings
- Files that should be ignored locally are shown as untracked
- git status shows more files than expected
Common causes
- The .git/info/exclude file doesn't exist (it's optional and not created by default)
- Insufficient permissions to read the .git/info/exclude file
- The .git/info directory is missing or has incorrect permissions
- Filesystem corruption or access issues with the .git directory
- Git for Windows bug with network drives or certain filesystems (fscache issue)
- SELinux or AppArmor policies blocking access to the file
- Incorrect file path specified in core.excludesfile configuration
- A directory exists where the file should be
How to fix "warning: unable to access '.git/info/exclude': Permission denied"
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.
Advanced notes
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.
Frequently asked questions
- What does "warning: unable to access '.git/info/exclude': Permission denied" mean?
- git/info/exclude file is a special Git configuration file that stores ignore patterns specific to your local repository. 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.
- How do I fix "warning: unable to access '.git/info/exclude': Permission denied"?
- 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.
- What causes "warning: unable to access '.git/info/exclude': Permission denied"?
- The .git/info/exclude file doesn't exist (it's optional and not created by default) Insufficient permissions to read the .git/info/exclude file The .git/info directory is missing or has incorrect permissions
- Is the "warning: unable to access '.git/info/exclude': Permission denied" error serious?
- It is a low-severity error โ more of a blocker than a risk. The steps above resolve it.
Official resources & further reading
- ๐Git Official Documentation
- ๐
- ๐ฌ
- ๐ฌ