Global gitignore File
When working with a version control system, you normally have files that are not ignored in some projects but you would like to ignore in globally in your workstation environment. The ways to do that are listed below.
Option 1: The git/ignore file in the home directory
The user’s ignore file is mentioned briefly in the Git documentation. You can add here your ignore rules the same way as you do it with your project .gitignore rules.
NOTE: This file will not exist by default so you have to manually create it.
*nix
~/.config/git/ignore
Windows
%USERPROFILE%\git\ignore
Option 2: Using core.excludesFile
The core.excludesFile option is metioned in the Git documentation.
Follow the commands below to set-up your global gitignore file.
NOTE: You can use any file name and path you want but I’ve used
.gitignore
in the user’s home directory the examples below to make it consistent with typical preferences.
*nix
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"