Git - gitignore


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

Option Commited Scope
gitignore Yes Only a specific Repository
infoexclude No Only a specific Repository
coreexcludesfile 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 infoexclude file

  • */: Ignore directories
  • *: Ignore file and directories.


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

Discover More
Git - Repository (Directory)

This page is the notion of repository and how it's implemented in Git. The git repository is a subdirectory named .git that contains all repository files. It contains : commit log configuration,...

Share this page:
Follow us:
Task Runner