๐ŸŽ“ A1Learner
๐Ÿ”
0 of 50 lessons completed

Ignore Patterns

A pattern matches many files at once. One line can hide every log file, every build folder, or every secret.

Hide every log file

Line 3 of the file hides the log file.

$ git check-ignore -v app.log

List the hidden files

The marks say it plainly: ?? means untracked, !! means ignored.

$ git status --ignored --short

Example

$ git status --ignored --short

Key points

  • A star matches any characters in a file name.
  • *.log matches every file that ends in .log.
  • A folder name with a slash hides a whole folder.
  • A ! at the start keeps one file out of a rule.
  • Rules read top to bottom. A later rule wins over an earlier one.
  • A tracked file never hides, even when a rule names it.
  • The ignored form of status lists the hidden files.

Here, two files are hidden and one waits to be staged. The marks say it plainly: ?? means untracked, !! means ignored.

Try it Yourself

Edit the code, then press Run.

Running is simulated

Exercise

What does *.log match?