CodeBlanks Logo Icon CodeBlanks

Global ignore

Learn to exclude personal files with a global .gitignore.

Global .gitignore

A project-level .gitignore stores rules for a specific repository. A global ignore file provides personal ignore rules that can apply across all repositories on your computer. For example, you do not need to list operating system or editor-specific files separately in every project.

git config --global core.excludesfile ~/.gitignore_global

This setting tells Git where to find your personal ignore file.

Configure the global file location

The core.excludesfile configuration setting tells Git where the global ignore file is located. The --global option applies the setting at the user level. This means the setting belongs to the user's Git configuration rather than a single repository.

git config --global core.excludesfile ~/.gitignore_global

You can create the specified file and write your personal patterns inside it.

Practice Write the global ignore setting

Set Git's global ignore file to ~/.gitignore_global. Use the git config command and the required option.

Starter code

terminal
# Global ignore dosyasının konumunu ayarla
# Komutu buraya yaz

Sample solution

terminal
# Global ignore dosyasının konumunu ayarla
git config --global core.excludesfile ~/.gitignore_global

Expected output

global ignore dosyası ~/.gitignore_global olarak ayarlanır

Questions and answers

Review the lesson questions together with their answers. To test yourself, solve the lesson interactively.

1 You want to ignore temporary files created by your editor in every Git repository on your computer. Which approach is suitable?

  • Run git init in every repository
  • Commit every file
  • Create the same file manually in every repository
  • Use a global ignore file Correct answer

Explanation: A global ignore file lets you use personal ignore rules across repositories without repeating them.

2 Complete the global ignore file setting

Question
git config --global core.____
Answer
git config --global core.excludesfile

Explanation: <code>core.excludesfile</code> is the setting that specifies the location of Git's global ignore file.

3 Global ignore concepts

Term Meaning
Global ignore Personal ignores across repositories
core.excludesfile Location of the ignore file
--global User-level configuration
Personal Rules specific to the user

All lessons in Beginner