Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Global Git ignore

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:

*.tmproj 

But it is not ignoring this type of files, any idea what I am doing wrong?

like image 487
Mild Fuzz Avatar asked Sep 07 '11 14:09

Mild Fuzz


People also ask

Is there a global Git ignore?

You can set up a global . gitignore file that lists files that will be ignored on all Git projects. This is the preferred way of ignoring editor artifacts, toolchain log files, OS files, and other miscellaneous crap.

What is the command to do global Git ignore?

Run git config --global core. excludesfile ~/. gitignore_global . According to this page at git-scm.com this command will make all the patterns from ~/.

Where is Git global ignore file?

Also, the default and automatic global gitignore file is $HOME/. config/git/ignore .


1 Answers

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' 

Windows cmd:

git config --global core.excludesFile "%USERPROFILE%\.gitignore" 

Windows PowerShell:

git config --global core.excludesFile "$Env:USERPROFILE\.gitignore" 

For Windows it is set to the location C:\Users\{myusername}\.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 %USERPROFILE% string.

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)

You can read about the command at https://help.github.com/articles/ignoring-files/#create-a-global-gitignore

like image 61
CB Bailey Avatar answered Sep 28 '22 02:09

CB Bailey