How to fix warning: unable to access global gitignore file in Git
Git cannot access the global gitignore file specified in core.excludesfile configuration. This warning appears when the configured path does not exist or is inaccessible.
Quick fix
Fixes warning: unable to access global gitignore file
git config --global core.excludesfile- Check the configured global gitignore path
- Create the missing global gitignore file
- Populate the global gitignore with common patterns
- Set core.excludesfile with absolute path
git config --global core.excludesfilewarning: unable to access global gitignore file
What this error means
This warning occurs when Git tries to read the global gitignore file (configured via core.excludesfile) but cannot find or access it. The global gitignore file is used to specify ignore patterns that apply across all repositories on your system, typically for editor-specific files like .vscode/ or operating system files like .DS_Store. When Git encounters this issue, it will continue to work normally but will only use repository-specific .gitignore files and the .git/info/exclude file. Files that should be ignored globally may still appear in git status or be accidentally committed. The configuration setting core.excludesfile points to a file location, but Git does not automatically create this file - you must create it manually. If the path contains typos, uses a relative path incorrectly, or points to a file that was deleted, this warning will appear.
Typical symptoms
- Warning message "unable to access global gitignore file" appears when running git commands
- Files like .DS_Store or .vscode/ appear in git status across multiple repositories
- Running `git config --global core.excludesfile` shows a path that does not exist
- Editor-specific or OS-specific files are not being ignored globally as expected
- The warning appears after setting up a new machine or user account
Common causes
- The global gitignore file was configured but never created
- Typo in the file path when setting core.excludesfile (e.g., "excludefile" instead of "excludesfile")
- Relative path used instead of absolute path in core.excludesfile configuration
- The global gitignore file was deleted or moved after being configured
- Local repository config has incorrect core.excludesfile that overrides global setting
- Windows path encoding issues or incorrect use of environment variables like %USERPROFILE%
How to fix "warning: unable to access global gitignore file"
First, verify what path Git is trying to access:
git config --global core.excludesfileIf this returns nothing, Git is using the default location ~/.config/git/ignore. If it returns a path, verify whether that file exists:
ls -la ~/.gitignore_global # Replace with your configured pathCreate the file at the configured location:
# If using the default location
mkdir -p ~/.config/git
touch ~/.config/git/ignoreOr if you have a custom location configured:
touch ~/.gitignore_global # Replace with your configured pathAdd common patterns that should be ignored across all repositories:
# macOS
.DS_Store
.AppleDouble
.LSOverride
# Windows
Thumbs.db
Desktop.ini
# Linux
*~
# Editors
.vscode/
.idea/
*.swp
*.swo
.sublime-project
.sublime-workspace
# Other
.envrcYou can use [gitignore.io](https://www.toptal.com/developers/gitignore) to generate patterns for your specific setup.
If the path is incorrect or missing, configure it properly with an absolute path:
# Using tilde expansion (recommended)
git config --global core.excludesfile ~/.gitignore_globalOn Windows (use forward slashes):
git config --global core.excludesfile C:/Users/YourUsername/.gitignore_globalAvoid using relative paths as they are interpreted relative to each repository.
If the issue persists in a specific repository, check if local config is overriding the global setting:
# Inside the repository
git config core.excludesfileIf this returns a different (incorrect) path, remove it:
git config --unset core.excludesfileOr edit .git/config directly and remove the [core] section entry for excludesfile.
Confirm Git can now access the file:
# This should complete without warnings
git statusTest that patterns are working:
# Create a test file that should be ignored
touch .DS_Store
git status # Should not show .DS_StoreUse git check-ignore to debug specific files:
git check-ignore -v .DS_Store
# Should show: ~/.gitignore_global:1:.DS_StoreAdvanced notes
Common pitfall: the configuration key is core.excludesfile (with "file"), not core.excludesfiles (plural). Git will not warn you about typos in configuration keys, so double-check the spelling.
Default location: If you do not set core.excludesfile, Git looks for $XDG_CONFIG_HOME/git/ignore or ~/.config/git/ignore by default. Using this default location means you do not need to configure anything - just create the file.
Best practices: Global gitignore should contain only editor-specific, IDE-specific, or OS-specific patterns (like .vscode/, .idea/, .DS_Store, Thumbs.db). Project-specific ignores (like node_modules/, dist/, .env) should go in the repository's .gitignore file so they are shared with other developers.
Windows-specific: If using PowerShell to set the path, it may not expand environment variables correctly. Use cmd.exe or hard-code the full path with forward slashes. Also ensure the file encoding is UTF-8 or ANSI, not UTF-16 LE.
Already tracked files: If files matching your global ignore patterns are already tracked by Git, they will not be ignored. You must first untrack them with git rm --cached <file> before the ignore rules take effect.
Frequently asked questions
- What does "warning: unable to access global gitignore file" mean?
- excludesfile) but cannot find or access it. DS_Store. git/info/exclude file.
- How do I fix "warning: unable to access global gitignore file"?
- Git cannot access the global gitignore file specified in core.excludesfile configuration. This warning appears when the configured path does not exist or is inaccessible.
- What causes "warning: unable to access global gitignore file"?
- The global gitignore file was configured but never created Typo in the file path when setting core.excludesfile (e.g., "excludefile" instead of "excludesfile") Relative path used instead of absolute path in core.excludesfile configuration
- Is the "warning: unable to access global gitignore file" 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
- ๐
- ๐ฌStack Overflow: global git ignore(Stack Overflow)
- ๐ฌStack Overflow: git global ignore not working(Stack Overflow)
- ๐
- ๐
- ๐
- ๐
- ๐