1GIT-IGNORE(1)                     Git Extras                     GIT-IGNORE(1)
2
3
4

NAME

6       git-ignore - Add .gitignore patterns
7

SYNOPSIS

9       git-ignore [<context>] [<pattern> [<pattern>]...]
10

DESCRIPTION

12       Adds  the  given  _pattern_s to a .gitignore file if it doesn´t already
13       exist.
14

OPTIONS

16       <context>
17
18       -l, --local
19
20       Sets the context to the .gitignore file in the current  working  direc‐
21       tory. (default)
22
23       -g, --global
24
25       Sets the context to the global gitignore file for the current user.
26
27       -p, --private
28
29       Sets  the  context  to  the  private  exclude  file  for the repository
30       (.git/info/exclude).
31
32       <pattern>
33
34       A space delimited list of patterns to append to the file in context.
35
36   PATTERN FORMAT
37       Pattern format as described in the git manual
38
39       ·   A blank line matches no files, so it can serve as a  separator  for
40           readability. To append a blank line use empty quotes "".
41
42       ·   A line starting with # serves as a comment. For example, "# This is
43           a comment"
44
45       ·   An optional prefix ! which negates the pattern; any  matching  file
46           excluded  by  a  previous  pattern will become included again. If a
47           negated pattern matches, this will override lower  precedence  pat‐
48           terns  sources. To use an exclamation ! as command line argument it
49           is best placed between single quotes ´´. For example, ´!src´
50
51       ·   If the pattern ends with a slash, it is removed for the purpose  of
52           the  following  description,  but it would only find a match with a
53           directory. In other words, foo/ will  match  a  directory  foo  and
54           paths  underneath  it,  but will not match a regular file or a sym‐
55           bolic link foo (this is consistent with the way how pathspec  works
56           in general in git).
57
58       ·   If the pattern does not contain a slash /, git treats it as a shell
59           glob pattern and checks for a match against the  pathname  relative
60           to  the  location of the .gitignore file (relative to the top level
61           of the work tree if not from a .gitignore file).
62
63       ·   Otherwise, git treats the pattern as a shell glob suitable for con‐
64           sumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the
65           pattern will not match a / in the pathname. For example,  "Documen‐
66           tation/*.html" matches "Documentation/git.html" but not "Documenta‐
67           tion/ppc/ppc.html" or "tools/perf/Documentation/perf.html".
68
69       ·   A leading slash matches the beginning of the pathname. For example,
70           "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
71
72
73

EXAMPLES

75       All  arguments  are  optional  so calling git-ignore alone will display
76       first the global then the local gitignore files:
77
78
79
80           $ git ignore
81           Global gitignore: /home/alice/.gitignore
82           # Numerous always-ignore extensions
83           *.diff
84           *.err
85           *.orig
86           *.rej
87           *.swo
88           *.swp
89           *.vi
90           *~
91           *.sass-cache
92
93           # OS or Editor folders
94           Thumbs.db
95           ---------------------------------
96           Local gitignore: .gitignore
97           nbproject
98
99
100
101       If you only want to see the global context use  the  --global  argument
102       (for local use --local):
103
104
105
106           $ git ignore
107           Global gitignore: /home/alice/.gitignore
108           Thumbs.db
109
110
111
112       To quickly append a new pattern to the default/local context simply:
113
114
115
116           $ git ignore *.log
117           Adding pattern(s) to: .gitignore
118
119
120
121       You can now configure any patterns without ever using an editor, with a
122       context and pattern arguments:  The  resulting  configuration  is  also
123       returned for your convenience.
124
125
126
127           $ git ignore --local "" "# Temporary files" *.tmp "*.log" tmp/*  "" "# Files I´d like to keep" ´!work´  ""
128           Adding pattern(s) to: .gitignore
129
130           Local gitignore: .gitignore
131
132           # Temporary files
133           index.tmp
134           *.log
135
136           # Files I´d like to keep
137           !work
138
139
140

AUTHOR

142       Written  by  Tj  Holowaychuk  <tj@vision-media.ca>  and  Tema Bolshakov
143       <tweekane@gmail.com> and Nick Lombard <github@jigsoft.co.za>
144

REPORTING BUGS

146       <https://github.com/tj/git-extras/issues>
147

SEE ALSO

149       <https://github.com/tj/git-extras>
150
151
152
153                                  April 2018                     GIT-IGNORE(1)
Impressum