GIT-IGNORE(1) | Git Extras | GIT-IGNORE(1) |
git-ignore - Add .gitignore patterns
git-ignore [<context>] [<pattern> [<pattern>]...]
Adds the given _pattern_s to a .gitignore file if it doesn´t already exist.
<context>
-l, --local
Sets the context to the .gitignore file in the current working directory. (default)
-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 (.git/info/exclude).
<pattern>
A space delimited list of patterns to append to the file in context.
Pattern format as described in the git manual
All arguments are optional so calling git-ignore alone will display first the global then the local gitignore files:
$ 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.
$ 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
Written by Tj Holowaychuk <tj@vision-media.ca> and Tema Bolshakov <tweekane@gmail.com> and Nick Lombard <github@jigsoft.co.za>
<https://github.com/tj/git-extras/issues>
<https://github.com/tj/git-extras>
September 2018 |