GIT-IGNORE(1)
π NAME
git-ignore β bestie, this adds .gitignore patterns for you, no editor required π
β¨ SYNOPSIS
git-ignore [<context>] [<pattern> [<pattern>]...]
π DESCRIPTION
It takes the patterns you hand it and appends them to a .gitignore file β but ONLY if that pattern isn't already chillin' in there. No duplicates, no mess, we're not about that life. β¨
πΈ OPTIONS
context
-l,--localβ sets the context to the.gitignorefile in the current working directory. (this is the default, bestie, it just happens)-g,--globalβ sets the context to the global gitignore file for the current user. π-p,--privateβ sets the context to the private exclude file for the repository, aka.git/info/exclude. π€«
pattern
A space delimited list of patterns to append to the file in context. Yes, space delimited. The shell is doing the splitting, not us. π«Ά
β PATTERN FORMAT
Pattern format as described in the git manual. Not me quoting the git manual, but likeβ¦ respectfully. π
- A blank line matches no files, so it can serve as a separator for readability. To append a blank line use empty quotes
"". π - A line starting with
#serves as a comment. For example,"# This is a comment". - An optional prefix
!which negates the pattern; any matching file excluded by a previous pattern will become included again. If a negated pattern matches, this will override lower precedence patterns sources. To use an exclamation!as command line argument it is best placed between single quotes''. For example,'!src'. - If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory. In other words,
foo/will match a directoryfooand paths underneath it, but will not match a regular file or a symbolic linkfoo(this is consistent with the way how pathspec works in general in git). - If the pattern does not contain a slash
/, git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the.gitignorefile (relative to the top level of the work tree if not from a.gitignorefile). - Otherwise, git treats the pattern as a shell glob suitable for consumption by
fnmatch(3)with theFNM_PATHNAMEflag: wildcards in the pattern will not match a/in the pathname. For example,"Documentation/*.html"matches"Documentation/git.html"but not"Documentation/ppc/ppc.html"or"tools/perf/Documentation/perf.html". - A leading slash matches the beginning of the pathname. For example,
"/*.c"matches"cat-file.c"but not"mozilla-sha1/sha1.c".
π¦ EXAMPLES
Okay so every argument is optional, which means calling git-ignore with literally nothing will show you first the global and then the local gitignore files. Iconic behaviour tbh:
$ git ignore
Global gitignore: /home/alice/.gitignore
# Numerous always-ignore extensions
*.diff
*.err
*.orig
*.rej
*.swo
*.swp
*.vi
*~
*.sass-cache
# OS or Editor folders
.DS_Store
.Trashes
._*
Thumbs.db
---------------------------------
Local gitignore: .gitignore
.cache
.project
.settings
.tmproj
nbproject
If you only want to see the global context use the --global argument (for local use --local):
$ git ignore
Global gitignore: /home/alice/.gitignore
.DS_Store
.Trashes
._*
Thumbs.db
To quickly append a new pattern to the default/local context simply:
$ git ignore *.log
Adding pattern(s) to: .gitignore
... adding '*.log'
You can now configure any patterns without ever using an editor, with a context and pattern arguments: The resulting configuration is also returned for your convenience. Bestie. You never have to open vim for this again. ππ«Ά
$ git ignore --local "" "# Temporary files" *.tmp "*.log" tmp/* "" "# Files I'd like to keep" '!work' ""
Adding pattern(s) to: .gitignore
... adding ''
... adding '# Temporary files'
... adding 'index.tmp'
... adding '*.log'
... adding 'tmp/*'
... adding ''
... adding '# Files I'd like to keep'
... adding '!work'
... adding ''
Local gitignore: .gitignore
# Temporary files
index.tmp
*.log
# Files I'd like to keep
!work
π AUTHOR
Written by Tj Holowaychuk <tj@vision-media.ca> and Tema Bolshakov <tweekane@gmail.com> and Nick Lombard <github@jigsoft.co.za>
π REPORTING BUGS
Found a bug? Not the vibe. Tell them here: https://github.com/tj/git-extras/issues
π SEE ALSO
https://github.com/tj/git-extras
okay that's the whole thing bestie, you ate that π
β¨ this is the git-ignore page from the Git Extras set, dated May 2026 β go forth and ignore files, fr fr π¦π
π¦ where this page comes from
- ubuntu stonking: git-extras 7.5.0-1 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms