I want to set up Git to globally ignore certain files.
I have added a
.gitignore file to my home directory (
/Users/me/) and I have added the following line to it:
But it is not ignoring this type of files, any idea what I am doing wrong?
You need to set up your global
core.excludesfile configuration file to point to this global ignore file e.g:
*nix or Windows git bash:
git config --global core.excludesFile '~/.gitignore'
git config --global core.excludesFile "%USERPROFILE%\.gitignore"
git config --global core.excludesFile "$Env:USERPROFILE\.gitignore"
For Windows it is set to the location
C:\Users\%username%\.gitignore. You can verify that the config value is correct by doing:
git config --global core.excludesFile
The result should be the expanded path to your user profile's
.gitignore. Ensure that the value does not contain the unexpanded
Important: The above commands will only set the location of the ignore file that git will use. The file has to still be manually created in that location and populated with the ignore list. (from muruge's comment)