Documentation / gitignore.txton commit add storage size output to 'git verify-pack -v' (5f4347b)
   1gitignore(5)
   2============
   3
   4NAME
   5----
   6gitignore - Specifies intentionally untracked files to ignore
   7
   8SYNOPSIS
   9--------
  10$GIT_DIR/info/exclude, .gitignore
  11
  12DESCRIPTION
  13-----------
  14
  15A `gitignore` file specifies intentionally untracked files that
  16git should ignore.  Each line in a `gitignore` file specifies a
  17pattern.
  18
  19When deciding whether to ignore a path, git normally checks
  20`gitignore` patterns from multiple sources, with the following
  21order of precedence, from highest to lowest (within one level of
  22precedence, the last matching pattern decides the outcome):
  23
  24 * Patterns read from the command line for those commands that support
  25   them.
  26
  27 * Patterns read from a `.gitignore` file in the same directory
  28   as the path, or in any parent directory, with patterns in the
  29   higher level files (up to the root) being overridden by those in
  30   lower level files down to the directory containing the file.
  31   These patterns match relative to the location of the
  32   `.gitignore` file.  A project normally includes such
  33   `.gitignore` files in its repository, containing patterns for
  34   files generated as part of the project build.
  35
  36 * Patterns read from `$GIT_DIR/info/exclude`.
  37
  38 * Patterns read from the file specified by the configuration
  39   variable 'core.excludesfile'.
  40
  41The underlying git plumbing tools, such as
  42linkgit:git-ls-files[1] and linkgit:git-read-tree[1], read
  43`gitignore` patterns specified by command-line options, or from
  44files specified by command-line options.  Higher-level git
  45tools, such as linkgit:git-status[1] and linkgit:git-add[1],
  46use patterns from the sources specified above.
  47
  48Patterns have the following format:
  49
  50 - A blank line matches no files, so it can serve as a separator
  51   for readability.
  52
  53 - A line starting with # serves as a comment.
  54
  55 - An optional prefix '!' which negates the pattern; any
  56   matching file excluded by a previous pattern will become
  57   included again.  If a negated pattern matches, this will
  58   override lower precedence patterns sources.
  59
  60 - If the pattern ends with a slash, it is removed for the
  61   purpose of the following description, but it would only find
  62   a match with a directory.  In other words, `foo/` will match a
  63   directory `foo` and paths underneath it, but will not match a
  64   regular file or a symbolic link `foo` (this is consistent
  65   with the way how pathspec works in general in git).
  66
  67 - If the pattern does not contain a slash '/', git treats it as
  68   a shell glob pattern and checks for a match against the
  69   pathname without leading directories.
  70
  71 - Otherwise, git treats the pattern as a shell glob suitable
  72   for consumption by fnmatch(3) with the FNM_PATHNAME flag:
  73   wildcards in the pattern will not match a / in the pathname.
  74   For example, "Documentation/\*.html" matches
  75   "Documentation/git.html" but not
  76   "Documentation/ppc/ppc.html".  A leading slash matches the
  77   beginning of the pathname; for example, "/*.c" matches
  78   "cat-file.c" but not "mozilla-sha1/sha1.c".
  79
  80An example:
  81
  82--------------------------------------------------------------
  83    $ git-status
  84    [...]
  85    # Untracked files:
  86    [...]
  87    #       Documentation/foo.html
  88    #       Documentation/gitignore.html
  89    #       file.o
  90    #       lib.a
  91    #       src/internal.o
  92    [...]
  93    $ cat .git/info/exclude
  94    # ignore objects and archives, anywhere in the tree.
  95    *.[oa]
  96    $ cat Documentation/.gitignore
  97    # ignore generated html files,
  98    *.html
  99    # except foo.html which is maintained by hand
 100    !foo.html
 101    $ git-status
 102    [...]
 103    # Untracked files:
 104    [...]
 105    #       Documentation/foo.html
 106    [...]
 107--------------------------------------------------------------
 108
 109Another example:
 110
 111--------------------------------------------------------------
 112    $ cat .gitignore
 113    vmlinux*
 114    $ ls arch/foo/kernel/vm*
 115    arch/foo/kernel/vmlinux.lds.S
 116    $ echo '!/vmlinux*' >arch/foo/kernel/.gitignore
 117--------------------------------------------------------------
 118
 119The second .gitignore prevents git from ignoring
 120`arch/foo/kernel/vmlinux.lds.S`.
 121
 122Documentation
 123-------------
 124Documentation by David Greaves, Junio C Hamano, Josh Triplett,
 125Frank Lichtenheld, and the git-list <git@vger.kernel.org>.
 126
 127GIT
 128---
 129Part of the linkgit:git[7] suite