Git - gitignore

About

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

Options

.gitignore

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.

info/exclude

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

Location

$GIT_DIR/info/exclude
# 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

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