Git - gitignore


How to tell git to ignore files or directory with ignore patterns.

Option Commited Scope
gitignore Yes Only a specific Repository
info/exclude No Only a specific Repository
core.excludesfile No All repository on the system



If you shouldn’t create a .gitignore file because you may accidentally set it under another version control, the solution is to create the info/exclude file


Exclude only for a repository in git_dir by creating the info/exclude file either as a symbolic link or as a regular file.


# Lines that start with '#' are comments.
# For a project mostly in C, the following would be a good set of
# exclude patterns (uncomment them if you want to use them):
# *.[oa]
# *~

Example as command line option of git

git ls-files --others --exclude-from=.git/info/exclude


core.excludesfile specifies a path to a file containing patterns of file names to exclude for all repository

  • See the global gitignore file for your system
git config --global core.excludesfile
  • Set it
git config --global core.excludesfile fullPathGitIgnore

Documentation / Reference

Powered by ComboStrap