← ← Back to articles
Jonatan Machado
● post
Set Up a Global .gitignore in Git
#git
Set Up a Global .gitignore in Git
Benefits of a global .gitignore:
- Keeps ignore patterns consistent across all your projects.
- Lets you ignore files that are specific to your user environment.
Things to be careful about:
- It can confuse team members because each person may have different settings.
- Make sure you never accidentally ignore files that are important to the project.
- Create or edit the .gitignore_global file: First, create or edit the
.gitignore_globalfile in your home directory. You can do that with the following command:
nano ~/.gitignore_global
Add the file or directory patterns you want to ignore globally. For example:
*.log
*.tmp
.madock
- Configure Git to use the .gitignore_global file: Tell Git to use that file as the global ignore file. Run the command below in your terminal:
git config --global core.excludesfile ~/.gitignore_global
- Verify the configuration: To check that the configuration was applied correctly, run:
git config --get core.excludesfile