.gitignore: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
No edit summary
Line 8: Line 8:


=Overview=
=Overview=
.gitingore specifies files to exclude from tracking. Files that are already tracked are not affected if a pattern that matches is specified in .gitignore after they Git started to track them.
Each line in the file specifies a [[#Pattern_Format|path pattern]], and when deciding to ignore or not a path, Git flattens the specifications from a set of files, while enforcing this precedence, listed here from highest to lowest:
* Pattern specified on command line
* Patterns read from a .gitignore file in the same directory as the path.
* Patterns read from .gitignore files from parent directories. The patterns specified in .gitignore closer to the path in the hierarchy take precedence over those specified in more distant .gitignore files, along the directory hierarchy.
* Patterns read from $GIT_DIR/info/exclude.
* Patterns read from the file specified by the configuration variable core.excludeFiles.
Specify the files that all developers should ignore into .gitignore file(s) checked into the repository itself. Patterns that are specific to a particular repository but which do not need to be shared with other related repositories (auxiliary files that live inside the repository but are specific to one user's workflow) should go into $GIT_DIR/info/exclude. Patterns which a user wants Git to ignore in all situations (backup or temporary files generated by the user’s editor of choice) generally go into a file specified by core.excludesFile in the user’s ~/.gitconfig. Its default value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead.
=Pattern Format=


=Reference .gitignore=
=Reference .gitignore=

Revision as of 17:08, 9 December 2020

External

Internal

Overview

.gitingore specifies files to exclude from tracking. Files that are already tracked are not affected if a pattern that matches is specified in .gitignore after they Git started to track them.

Each line in the file specifies a path pattern, and when deciding to ignore or not a path, Git flattens the specifications from a set of files, while enforcing this precedence, listed here from highest to lowest:

  • Pattern specified on command line
  • Patterns read from a .gitignore file in the same directory as the path.
  • Patterns read from .gitignore files from parent directories. The patterns specified in .gitignore closer to the path in the hierarchy take precedence over those specified in more distant .gitignore files, along the directory hierarchy.
  • Patterns read from $GIT_DIR/info/exclude.
  • Patterns read from the file specified by the configuration variable core.excludeFiles.

Specify the files that all developers should ignore into .gitignore file(s) checked into the repository itself. Patterns that are specific to a particular repository but which do not need to be shared with other related repositories (auxiliary files that live inside the repository but are specific to one user's workflow) should go into $GIT_DIR/info/exclude. Patterns which a user wants Git to ignore in all situations (backup or temporary files generated by the user’s editor of choice) generally go into a file specified by core.excludesFile in the user’s ~/.gitconfig. Its default value is $XDG_CONFIG_HOME/git/ignore. If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/ignore is used instead.


Pattern Format

Reference .gitignore

https://github.com/ovidiuf/templates/blob/master/reference-gitignore

To download:

https://raw.githubusercontent.com/ovidiuf/templates/master/reference-gitignore

Use Cases

Negate an Exclusion Pattern Declared by Upper .gitignore Files

!