Interview Q&A / Git & GitHub

IntermediateQuick answer1 min readUpdated 3 Oct 2026

What is the difference between a project .gitignore and a global gitignore?

SHORT ANSWER

The project .gitignore is committed and shared with the team. A global gitignore, set through core.excludesFile, applies to every repo on your machine and holds personal clutter like editor folders and OS files.

Explain it simply

Project rules are the shared house rules: everyone ignores node_modules and build output. Personal clutter, such as .DS_Store, .idea/ or Thumbs.db, belongs to your own habits, so it should not be in every project's file.

Create ~/.gitignore_global, list your editor and OS files, and tell Git about it with git config --global core.excludesFile. There is also .git/info/exclude, which works like a gitignore but is local to one repo and never committed.

Example

bash
git config --global core.excludesFile ~/.gitignore_global
echo ".DS_Store" >> ~/.gitignore_global
echo ".idea/" >> ~/.gitignore_global

What to say in the interview

"The project .gitignore is committed for the whole team. A global one, configured via core.excludesFile, holds my personal editor and OS files across all repos, and .git/info/exclude covers local-only rules for one repo."

#git#gitignore#config

Related questions

Practise more Git & GitHub questions

Test your recall with short answers, then return to the detailed explanations when you need context.

Open Git & GitHub quick answers →

Get new questions like this by email

One short email when something new and useful lands. No spam, unsubscribe in one tap.

By subscribing you agree to the Privacy Policy.