A global .gitignore file
suggest changeTo have Git ignore certain files across all repositories you can create a global .gitignore with the following command in your terminal or command prompt:
git config --global core.excludesfile <Path_To_Global_gitignore_file>
Git will now use this in addition to each repository’s own .gitignore file. Rules for this are:
- If the local
.gitignorefile explicitly includes a file while the global.gitignoreignores it, the local.gitignoretakes priority (the file will be included) - If the repository is cloned on multiple machines, the global
.gitignoremust be present on each of them. Otherwise a file ignored on one machine can still be committed from another, and the machine that ignores it will not pick up later changes to that file. This is why a repository-specific.gitignoreis a better idea than a global one if a team works on the project
This file is a good place to keep platform, machine, or user specific ignores, e.g. OS X .DS_Store, Windows Thumbs.db, or Vim *.ext~ and *.ext.swp ignores if you don’t want to keep those in the repository. So one team member working on OS X can ignore .DS_Store and _MACOSX (which is actually useless), while another team member on Windows can ignore Thumbs.db
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents