.gitignore files list files and directories that Git shouldn't include when adding/committing to repos. These include files that your operating system uses to function properly (like file icons and display settings).
Complete the following steps to set your global .gitignore file for all repos on your system.
These steps were taken from: Configuring ignored files for all repositories on your computer
-
Is your global
.gitignorefile already set up? The following shell command will print your settings for your.gitignore:$ git config core.excludesfileIf nothing happens, you need to set your excludes file.
-
Using VS Code (or similar) save a
.gitignore_globalfile to your home directory (usually in/Users/usernameor similar). In this file, paste the contents of theexcludesfilefile listed in this Gist. It includes files and directories for Windows, Mac and Linux. -
The following shell command will save your
.gitignore_globalfile in your settings:$ git config --global core.excludesfile ~/.gitignore_global -
Repeat Step 1 to confirm your settings were saved correctly.
And that's it! You will need to complete these steps for any computer you plan to use with Git.