mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
Updated docs.
This commit is contained in:
parent
91bf8dbaef
commit
99815fa425
|
|
@ -135,9 +135,9 @@ remove_patterns() {
|
|||
declare -a args
|
||||
local tmpfile
|
||||
args=( "${@:3}" )
|
||||
tmpfile="$(mktemp -q "${TMPDIR:-/tmp}"/git-extras-ignore.XXXXXX 2>/dev/null)"
|
||||
local file="${2/#~/$HOME}"
|
||||
if [ -f "$file" ]; then
|
||||
tmpfile="$(mktemp -q "${TMPDIR:-/tmp}"/git-extras-ignore.XXXXXX 2>/dev/null)"
|
||||
echo "Removing patterns from $1 gitignore: $2"
|
||||
awk -v outfile="$tmpfile" "${AWK_SCRIPT}"\
|
||||
<(printf '%s\n' "${args[@]}") "$file"
|
||||
|
|
@ -245,14 +245,17 @@ else
|
|||
local|none)
|
||||
cd_to_git_root --warn
|
||||
remove_patterns 'local' .gitignore "${args[@]}" && echo
|
||||
show_local
|
||||
;;
|
||||
global)
|
||||
global_gitignore="$(global_ignore)"
|
||||
remove_patterns global "$global_gitignore" "${args[@]}" && echo
|
||||
show_global
|
||||
;;
|
||||
private)
|
||||
cd_to_git_root --error
|
||||
remove_patterns private "${GIT_DIR}/info/exclude" "${args[@]}" && echo
|
||||
show_private
|
||||
;;
|
||||
esac
|
||||
exit 0
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ git-extras(1) -- Awesome GIT utilities
|
|||
- **git-graft(1)** Merge and destroy a given branch
|
||||
- **git-guilt(1)** calculate change between two revisions
|
||||
- **git-ignore-io(1)** Get sample gitignore file
|
||||
- **git-ignore(1)** Add .gitignore patterns
|
||||
- **git-ignore(1)** Modify or display .gitignore files
|
||||
- **git-info(1)** Returns information on current repository
|
||||
- **git-local-commits(1)** List local commits
|
||||
- **git-lock(1)** Lock a file excluded from version control
|
||||
|
|
|
|||
182
man/git-ignore.1
182
man/git-ignore.1
|
|
@ -1,77 +1,84 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "GIT\-IGNORE" "1" "April 2018" "" "Git Extras"
|
||||
.
|
||||
.\" generated with Ronn-NG/v0.10.1
|
||||
.\" http://github.com/apjanke/ronn-ng/tree/0.10.1
|
||||
.TH "GIT\-IGNORE" "1" "June 2026" "" "Git Extras"
|
||||
.SH "NAME"
|
||||
\fBgit\-ignore\fR \- Add \.gitignore patterns
|
||||
.
|
||||
\fBgit\-ignore\fR \- Modify or display \.gitignore files
|
||||
.SH "SYNOPSIS"
|
||||
\fBgit\-ignore\fR [<context>] [<pattern> [<pattern>]\.\.\.]
|
||||
.
|
||||
\fBgit\-ignore\fR [<context>] [<action>] [\-\-] [<pattern> [<pattern>]\|\.\|\.\|\.]
|
||||
.SH "DESCRIPTION"
|
||||
Adds the given _pattern_s to a \.gitignore file if it doesn\'t already exist\.
|
||||
.
|
||||
Modifies or shows \.gitignore of selected \fIcontext\fR\.
|
||||
.P
|
||||
Possible actions are: addition of new \fIpattern\fRs, removal of existing \fIpattern\fRs from gitignore files, opening these files in text editor or simply displaying their contents in current terminal (for details see flags/usage)\.
|
||||
.P
|
||||
Contexts are global (e\.g\. $HOME/\.gitignore or $HOME/\.local/\.git/\.gitignore), private (e\.g\. \|\.\|\.\|\./project/\.git/info/exclude) and local (e\.g\. \|\.\|\.\|\./project/\.gitignore)
|
||||
.P
|
||||
Adding only happens for \fIpattern\fRs that don't already exist in the file; removing \fIpattern\fRs that are not present does not do anything; editing fails if the file is not yet present\.
|
||||
.P
|
||||
At most 1 \fIcontext\fR and 1 \fIaction\fR matter for the program, the ones selected are the latest encountered in the flag list\.
|
||||
.P
|
||||
Default behavior:
|
||||
.IP "\(bu" 4
|
||||
If no flags or arguments are passed, prints gitignores of all 3 \fIcontext\fRs\.
|
||||
.IP "\(bu" 4
|
||||
Passing arguments with no \fIaction\fR implies addition of \fIpattern\fRs to gitignore\.
|
||||
.IP "\(bu" 4
|
||||
If an \fIaction\fR is chosen, but not \fIcontext\fR, \fIaction\fR is performed on local gitignore\.
|
||||
.IP "\(bu" 4
|
||||
If \fIcontext\fR is chosen but not action (not even implied), gitignore of chosen \fIcontext\fR is printed\.
|
||||
.IP "" 0
|
||||
.SH "OPTIONS"
|
||||
<context>
|
||||
.
|
||||
.P
|
||||
\-l, \-\-local
|
||||
.
|
||||
.P
|
||||
Sets the context to the \.gitignore file in the current working directory\. (default)
|
||||
.
|
||||
.P
|
||||
\-g, \-\-global
|
||||
.
|
||||
.P
|
||||
Sets the context to the global gitignore file for the current user\.
|
||||
.
|
||||
.P
|
||||
\-p, \-\-private
|
||||
.
|
||||
.P
|
||||
Sets the context to the private exclude file for the repository (\fB\.git/info/exclude\fR)\.
|
||||
.
|
||||
.P
|
||||
<action>
|
||||
.P
|
||||
\-e, \-\-edit
|
||||
.P
|
||||
Sets action to edit\. This will open gitignore in a text editor (editor selection is the same as for git commit)\. If no \fIcontext\fR is provided local is assumed\. Any \fIpattern\fR; provided in additional arguments is silently omitted\.
|
||||
.P
|
||||
\-r, \-\-remove
|
||||
.P
|
||||
Sets action to remove\. This will look for \fIpattern\fRs in gitignore of selected \fIcontext\fR and remove if finds them\. If no \fIpattern\fR is provided does nothing\. All characters in \fIpattern\fR are treated literally, no interpretation of metacharacters is performed as would be, for example, for a regex pattern\.
|
||||
.P
|
||||
<pattern>
|
||||
.
|
||||
.P
|
||||
A space delimited list of patterns to append to the file in context\.
|
||||
.
|
||||
.P
|
||||
\-\-
|
||||
.P
|
||||
End of options delimeter\. Everything to the right of it is treated as positional arguments or more precisely a \fIpattern\fR\.
|
||||
.SS "PATTERN FORMAT"
|
||||
Pattern format as described in the git manual
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
A blank line matches no files, so it can serve as a separator for readability\. To append a blank line use empty quotes ""\.
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
A line starting with # serves as a comment\. For example, "# This is a comment"
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
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\'
|
||||
.
|
||||
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'
|
||||
.IP "\(bu" 4
|
||||
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 directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in git)\.
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
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 \.gitignore file (relative to the top level of the work tree if not from a \.gitignore file)\.
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
Otherwise, git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: 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"\.
|
||||
.
|
||||
.IP "\(bu" 4
|
||||
A leading slash matches the beginning of the pathname\. For example, "/*\.c" matches "cat\-file\.c" but not "mozilla\-sha1/sha1\.c"\.
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.SH "EXAMPLES"
|
||||
All arguments are optional so calling git\-ignore alone will display first the global then the local gitignore files:
|
||||
.
|
||||
All arguments are optional so calling git\-ignore alone will display global, local and private gitignore files in order:
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ git ignore
|
||||
Global gitignore: /home/alice/\.gitignore
|
||||
# Numerous always\-ignore extensions
|
||||
|
|
@ -86,92 +93,101 @@ Global gitignore: /home/alice/\.gitignore
|
|||
*\.sass\-cache
|
||||
|
||||
# OS or Editor folders
|
||||
\.DS_Store
|
||||
\.Trashes
|
||||
\._*
|
||||
\&\.DS_Store
|
||||
\&\.Trashes
|
||||
\&\._*
|
||||
Thumbs\.db
|
||||
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
Local gitignore: \.gitignore
|
||||
\.cache
|
||||
\.project
|
||||
\.settings
|
||||
\.tmproj
|
||||
\&\.cache
|
||||
\&\.project
|
||||
\&\.settings
|
||||
\&\.tmproj
|
||||
nbproject
|
||||
.
|
||||
\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-\-
|
||||
Private gitignore: \.git/info/exclude
|
||||
notes\.txt
|
||||
test\.sh
|
||||
\&\.env\.local
|
||||
config\.json
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
If you only want to see the global context use the \-\-global argument (for local use \-\-local):
|
||||
.
|
||||
If you only want to see the global context use the \-\-global argument (for local use \-\-local, for private use \-\-private):
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ git ignore
|
||||
Global gitignore: /home/alice/\.gitignore
|
||||
\.DS_Store
|
||||
\.Trashes
|
||||
\._*
|
||||
\&\.DS_Store
|
||||
\&\.Trashes
|
||||
\&\._*
|
||||
Thumbs\.db
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
To quickly append a new pattern to the default/local context simply:
|
||||
.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ git ignore *\.log
|
||||
Adding pattern(s) to: \.gitignore
|
||||
\.\.\. adding \'*\.log\'
|
||||
.
|
||||
\|\.\|\.\|\. adding '*\.log'
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
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\.
|
||||
.
|
||||
You can now configure any patterns without ever using an editor (or use a shortcut to open file in editor when needed), with a context and pattern arguments: The resulting configuration is also returned for your convenience\.
|
||||
.IP "" 4
|
||||
.
|
||||
.nf
|
||||
|
||||
$ git ignore \-\-local "" "# Temporary files" *\.tmp "*\.log" tmp/* "" "# Files I\'d like to keep" \'!work\' ""
|
||||
$ 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 \'\'
|
||||
\|\.\|\.\|\. adding ''
|
||||
\|\.\|\.\|\. adding '# Temporary files'
|
||||
\|\.\|\.\|\. adding '*\.tmp'
|
||||
\|\.\|\.\|\. adding '*\.log'
|
||||
\|\.\|\.\|\. adding 'tmp/*'
|
||||
\|\.\|\.\|\. adding ''
|
||||
\|\.\|\.\|\. adding '# Files I'd like to keep'
|
||||
\|\.\|\.\|\. adding '!work'
|
||||
\|\.\|\.\|\. adding ''
|
||||
|
||||
Local gitignore: \.gitignore
|
||||
|
||||
# Temporary files
|
||||
index\.tmp
|
||||
*\.tmp
|
||||
*\.log
|
||||
tmp/*
|
||||
|
||||
# Files I\'d like to keep
|
||||
# Files I'd like to keep
|
||||
!work
|
||||
.
|
||||
.fi
|
||||
.
|
||||
.IP "" 0
|
||||
.
|
||||
.P
|
||||
Removing patterns works in a similar way\. Select context and pass patterns to be removed from the gitignore file\.
|
||||
.IP "" 4
|
||||
.nf
|
||||
$ git ignore \-l \-r "*\.log"
|
||||
Removing patterns from local gitignore: \.gitignore
|
||||
\|\.\|\.\|\. removing '*\.log'
|
||||
|
||||
Local gitignore: \.gitignore
|
||||
|
||||
# Temporary files
|
||||
*\.tmp
|
||||
tmp/*
|
||||
|
||||
# Files I'd like to keep
|
||||
!work
|
||||
.fi
|
||||
.IP "" 0
|
||||
.P
|
||||
If you want to open gitignore in an editor and do changes manually pass \-e flag:
|
||||
.IP "" 4
|
||||
.nf
|
||||
$ git ignore \-p \-e
|
||||
.fi
|
||||
.IP "" 0
|
||||
.SH "AUTHOR"
|
||||
Written by Tj Holowaychuk <\fItj@vision\-media\.ca\fR> and Tema Bolshakov <\fItweekane@gmail\.com\fR> and Nick Lombard <\fIgithub@jigsoft\.co\.za\fR>
|
||||
.
|
||||
Written by Tj Holowaychuk <\fItj@vision\-media\.ca\fR> and Tema Bolshakov <\fItweekane@gmail\.com\fR> and Nick Lombard <\fIgithub@jigsoft\.co\.za\fR> and Kirill Dergachev <\fIkdergachev1062@gmail\.com\fR>
|
||||
.SH "REPORTING BUGS"
|
||||
<\fIhttps://github\.com/tj/git\-extras/issues\fR>
|
||||
.
|
||||
.SH "SEE ALSO"
|
||||
<\fIhttps://github\.com/tj/git\-extras\fR>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,9 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv='content-type' value='text/html;charset=utf8'>
|
||||
<meta name='generator' value='Ronn/v0.7.3 (http://github.com/rtomayko/ronn/tree/0.7.3)'>
|
||||
<title>git-ignore(1) - Add .gitignore patterns</title>
|
||||
<meta http-equiv='content-type' content='text/html;charset=utf-8'>
|
||||
<meta name='generator' content='Ronn-NG/v0.10.1 (http://github.com/apjanke/ronn-ng/tree/0.10.1)'>
|
||||
<title>git-ignore(1) - Modify or display .gitignore files</title>
|
||||
<style type='text/css' media='all'>
|
||||
/* style: man */
|
||||
body#manpage {margin:0}
|
||||
|
|
@ -69,57 +69,110 @@
|
|||
<li class='tr'>git-ignore(1)</li>
|
||||
</ol>
|
||||
|
||||
<h2 id="NAME">NAME</h2>
|
||||
<p class="man-name">
|
||||
<code>git-ignore</code> - <span class="man-whatis">Add .gitignore patterns</span>
|
||||
</p>
|
||||
|
||||
|
||||
<h2 id="NAME">NAME</h2>
|
||||
<p class="man-name">
|
||||
<code>git-ignore</code> - <span class="man-whatis">Modify or display .gitignore files</span>
|
||||
</p>
|
||||
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
||||
|
||||
<p><code>git-ignore</code> [<context>] [<pattern> [<pattern>]...]</p>
|
||||
<p><code>git-ignore</code> [<context>] [<action>] [--] [<pattern> [<pattern>]...]</p>
|
||||
|
||||
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
||||
|
||||
<p>Adds the given _pattern_s to a .gitignore file if it doesn't already exist.</p>
|
||||
<p>Modifies or shows .gitignore of selected <em>context</em>.</p>
|
||||
|
||||
<p>Possible actions are: addition of new <em>pattern</em>s, removal of existing <em>pattern</em>s from gitignore files, opening these files in text editor or simply displaying their contents in current terminal (for details see flags/usage).</p>
|
||||
|
||||
<p>Contexts are global (e.g. $HOME/.gitignore or $HOME/.local/.git/.gitignore), private (e.g. .../project/.git/info/exclude) and local (e.g. .../project/.gitignore)</p>
|
||||
|
||||
<p>Adding only happens for <em>pattern</em>s that don't already exist in the file; removing <em>pattern</em>s that are not present does not do anything; editing fails if the file is not yet present.</p>
|
||||
|
||||
<p>At most 1 <em>context</em> and 1 <em>action</em> matter for the program, the ones selected are the latest encountered in the flag list.</p>
|
||||
|
||||
<p>Default behavior:</p>
|
||||
|
||||
<ul>
|
||||
<li>
|
||||
<p>If no flags or arguments are passed, prints gitignores of all 3 <em>context</em>s.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Passing arguments with no <em>action</em> implies addition of <em>pattern</em>s to gitignore.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>If an <em>action</em> is chosen, but not <em>context</em>, <em>action</em> is performed on local gitignore.</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>If <em>context</em> is chosen but not action (not even implied), gitignore of chosen <em>context</em> is printed.</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2 id="OPTIONS">OPTIONS</h2>
|
||||
|
||||
<p> <context></p>
|
||||
<p><context></p>
|
||||
|
||||
<p> -l, --local</p>
|
||||
<p>-l, --local</p>
|
||||
|
||||
<p> Sets the context to the .gitignore file in the current working directory. (default)</p>
|
||||
<p>Sets the context to the .gitignore file in the current working directory. (default)</p>
|
||||
|
||||
<p> -g, --global</p>
|
||||
<p>-g, --global</p>
|
||||
|
||||
<p> Sets the context to the global gitignore file for the current user.</p>
|
||||
<p>Sets the context to the global gitignore file for the current user.</p>
|
||||
|
||||
<p> -p, --private</p>
|
||||
<p>-p, --private</p>
|
||||
|
||||
<p> Sets the context to the private exclude file for the repository (<code>.git/info/exclude</code>).</p>
|
||||
<p>Sets the context to the private exclude file for the repository (<code>.git/info/exclude</code>).</p>
|
||||
|
||||
<p> <pattern></p>
|
||||
<p><action></p>
|
||||
|
||||
<p> A space delimited list of patterns to append to the file in context.</p>
|
||||
<p>-e, --edit</p>
|
||||
|
||||
<p>Sets action to edit. This will open gitignore in a text editor (editor selection is the same as for git commit). If no <em>context</em> is provided local is assumed. Any <em>pattern</em>; provided in additional arguments is silently omitted.</p>
|
||||
|
||||
<p>-r, --remove</p>
|
||||
|
||||
<p>Sets action to remove. This will look for <em>pattern</em>s in gitignore of selected <em>context</em> and remove if finds them. If no <em>pattern</em> is provided does nothing. All characters in <em>pattern</em> are treated literally, no interpretation of metacharacters is performed as would be, for example, for a regex pattern.</p>
|
||||
|
||||
<p><pattern></p>
|
||||
|
||||
<p>A space delimited list of patterns to append to the file in context.</p>
|
||||
|
||||
<p>--</p>
|
||||
|
||||
<p>End of options delimeter. Everything to the right of it is treated as positional arguments or more precisely a <em>pattern</em>.</p>
|
||||
|
||||
<h3 id="PATTERN-FORMAT">PATTERN FORMAT</h3>
|
||||
|
||||
<p>Pattern format as described in the git manual</p>
|
||||
|
||||
<ul>
|
||||
<li><p>A blank line matches no files, so it can serve as a separator for readability. To append a blank line use empty quotes "".</p></li>
|
||||
<li><p>A line starting with # serves as a comment. For example, "# This is a comment"</p></li>
|
||||
<li><p>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'</p></li>
|
||||
<li><p>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 directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in git).</p></li>
|
||||
<li><p>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 .gitignore file (relative to the top level of the work tree if not from a .gitignore file).</p></li>
|
||||
<li><p>Otherwise, git treats the pattern as a shell glob suitable for consumption by <span class="man-ref">fnmatch<span class="s">(3)</span></span> with the FNM_PATHNAME flag: 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".</p></li>
|
||||
<li><p>A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".</p></li>
|
||||
<li>
|
||||
<p>A blank line matches no files, so it can serve as a separator for readability. To append a blank line use empty quotes "".</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>A line starting with # serves as a comment. For example, "# This is a comment"</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>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'</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>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 directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in git).</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>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 .gitignore file (relative to the top level of the work tree if not from a .gitignore file).</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>Otherwise, git treats the pattern as a shell glob suitable for consumption by <span class="man-ref">fnmatch<span class="s">(3)</span></span> with the FNM_PATHNAME flag: 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".</p>
|
||||
</li>
|
||||
<li>
|
||||
<p>A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".</p>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
|
||||
<h2 id="EXAMPLES">EXAMPLES</h2>
|
||||
|
||||
<p> All arguments are optional so calling git-ignore alone will display first the global then the local gitignore files:</p>
|
||||
<p>All arguments are optional so calling git-ignore alone will display global, local and private gitignore files in order:</p>
|
||||
|
||||
<pre><code>$ git ignore
|
||||
Global gitignore: /home/alice/.gitignore
|
||||
|
|
@ -146,9 +199,15 @@ Local gitignore: .gitignore
|
|||
.settings
|
||||
.tmproj
|
||||
nbproject
|
||||
---------------------------------
|
||||
Private gitignore: .git/info/exclude
|
||||
notes.txt
|
||||
test.sh
|
||||
.env.local
|
||||
config.json
|
||||
</code></pre>
|
||||
|
||||
<p>If you only want to see the global context use the --global argument (for local use --local):</p>
|
||||
<p>If you only want to see the global context use the --global argument (for local use --local, for private use --private):</p>
|
||||
|
||||
<pre><code>$ git ignore
|
||||
Global gitignore: /home/alice/.gitignore
|
||||
|
|
@ -165,14 +224,14 @@ Adding pattern(s) to: .gitignore
|
|||
... adding '*.log'
|
||||
</code></pre>
|
||||
|
||||
<p>You can now configure any patterns without ever using an editor, with a context and pattern arguments:
|
||||
<p>You can now configure any patterns without ever using an editor (or use a shortcut to open file in editor when needed), with a context and pattern arguments:
|
||||
The resulting configuration is also returned for your convenience.</p>
|
||||
|
||||
<pre><code>$ 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 '*.tmp'
|
||||
... adding '*.log'
|
||||
... adding 'tmp/*'
|
||||
... adding ''
|
||||
|
|
@ -183,17 +242,39 @@ Adding pattern(s) to: .gitignore
|
|||
Local gitignore: .gitignore
|
||||
|
||||
# Temporary files
|
||||
index.tmp
|
||||
*.tmp
|
||||
*.log
|
||||
tmp/*
|
||||
|
||||
# Files I'd like to keep
|
||||
!work
|
||||
</code></pre>
|
||||
|
||||
<p>Removing patterns works in a similar way. Select context and pass patterns to be removed from the gitignore file.</p>
|
||||
|
||||
<pre><code>$ git ignore -l -r "*.log"
|
||||
Removing patterns from local gitignore: .gitignore
|
||||
... removing '*.log'
|
||||
|
||||
Local gitignore: .gitignore
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
tmp/*
|
||||
|
||||
# Files I'd like to keep
|
||||
!work
|
||||
</code></pre>
|
||||
|
||||
<p>If you want to open gitignore in an editor and do changes manually pass -e flag:</p>
|
||||
|
||||
<pre><code>$ git ignore -p -e
|
||||
</code></pre>
|
||||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Tj Holowaychuk <<a href="mailto:tj@vision-media.ca" data-bare-link="true">tj@vision-media.ca</a>> and Tema Bolshakov <<a href="mailto:tweekane@gmail.com" data-bare-link="true">tweekane@gmail.com</a>>
|
||||
and Nick Lombard <<a href="mailto:github@jigsoft.co.za" data-bare-link="true">github@jigsoft.co.za</a>></p>
|
||||
<p>Written by Tj Holowaychuk <<a href="mailto:tj@vision-media.ca" data-bare-link="true">tj@vision-media.ca</a>> and Tema Bolshakov <<a href="mailto:tweekane@gmail.com" data-bare-link="true">tweekane@gmail.com</a>>
|
||||
and Nick Lombard <<a href="mailto:github@jigsoft.co.za" data-bare-link="true">github@jigsoft.co.za</a>&gt and Kirill Dergachev <<a href="mailto:kdergachev1062@gmail.com" data-bare-link="true">kdergachev1062@gmail.com</a>></p>
|
||||
|
||||
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
|
||||
|
||||
|
|
@ -203,10 +284,9 @@ and Nick Lombard <<a href="mailto:g

|
|||
|
||||
<p><<a href="https://github.com/tj/git-extras" data-bare-link="true">https://github.com/tj/git-extras</a>></p>
|
||||
|
||||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>April 2018</li>
|
||||
<li class='tc'>June 2026</li>
|
||||
<li class='tr'>git-ignore(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,31 @@
|
|||
git-ignore(1) -- Add .gitignore patterns
|
||||
git-ignore(1) -- Modify or display .gitignore files
|
||||
========================================
|
||||
|
||||
## SYNOPSIS
|
||||
|
||||
`git-ignore` [<context>] [<pattern> [<pattern>]...]
|
||||
`git-ignore` [<context>] [<action>] [--] [<pattern> [<pattern>]...]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
Adds the given _pattern_s to a .gitignore file if it doesn't already exist.
|
||||
Modifies or shows .gitignore of selected *context*.
|
||||
|
||||
Possible actions are: addition of new *pattern*s, removal of existing *pattern*s from gitignore files, opening these files in text editor or simply displaying their contents in current terminal (for details see flags/usage).
|
||||
|
||||
Contexts are global (e.g. $HOME/.gitignore or $HOME/.local/.git/.gitignore), private (e.g. .../project/.git/info/exclude) and local (e.g. .../project/.gitignore)
|
||||
|
||||
Adding only happens for *pattern*s that don't already exist in the file; removing *pattern*s that are not present does not do anything; editing fails if the file is not yet present.
|
||||
|
||||
At most 1 *context* and 1 *action* matter for the program, the ones selected are the latest encountered in the flag list.
|
||||
|
||||
Default behavior:
|
||||
|
||||
* If no flags or arguments are passed, prints gitignores of all 3 *context*s.
|
||||
|
||||
* Passing arguments with no *action* implies addition of *pattern*s to gitignore.
|
||||
|
||||
* If an *action* is chosen, but not *context*, *action* is performed on local gitignore.
|
||||
|
||||
* If *context* is chosen but not action (not even implied), gitignore of chosen *context* is printed.
|
||||
|
||||
## OPTIONS
|
||||
|
||||
|
|
@ -25,10 +43,24 @@ Adds the given _pattern_s to a .gitignore file if it doesn't already exist.
|
|||
|
||||
Sets the context to the private exclude file for the repository (`.git/info/exclude`).
|
||||
|
||||
<action>
|
||||
|
||||
-e, --edit
|
||||
|
||||
Sets action to edit. This will open gitignore in a text editor (editor selection is the same as for git commit). If no *context* is provided local is assumed. Any *pattern*; provided in additional arguments is silently omitted.
|
||||
|
||||
-r, --remove
|
||||
|
||||
Sets action to remove. This will look for *pattern*s in gitignore of selected *context* and remove if finds them. If no *pattern* is provided does nothing. All characters in *pattern* are treated literally, no interpretation of metacharacters is performed as would be, for example, for a regex pattern.
|
||||
|
||||
<pattern>
|
||||
|
||||
A space delimited list of patterns to append to the file in context.
|
||||
|
||||
--
|
||||
|
||||
End of options delimeter. Everything to the right of it is treated as positional arguments or more precisely a *pattern*.
|
||||
|
||||
### PATTERN FORMAT
|
||||
|
||||
Pattern format as described in the git manual
|
||||
|
|
@ -43,14 +75,14 @@ Pattern format as described in the git manual
|
|||
|
||||
* 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 .gitignore file (relative to the top level of the work tree if not from a .gitignore file).
|
||||
|
||||
* Otherwise, git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: 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".
|
||||
* Otherwise, git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM\_PATHNAME flag: 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".
|
||||
* A leading slash matches the beginning of the pathname. For example, "/\*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
|
||||
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
All arguments are optional so calling git-ignore alone will display first the global then the local gitignore files:
|
||||
All arguments are optional so calling git-ignore alone will display global, local and private gitignore files in order:
|
||||
|
||||
$ git ignore
|
||||
Global gitignore: /home/alice/.gitignore
|
||||
|
|
@ -77,8 +109,14 @@ Pattern format as described in the git manual
|
|||
.settings
|
||||
.tmproj
|
||||
nbproject
|
||||
---------------------------------
|
||||
Private gitignore: .git/info/exclude
|
||||
notes.txt
|
||||
test.sh
|
||||
.env.local
|
||||
config.json
|
||||
|
||||
If you only want to see the global context use the --global argument (for local use --local):
|
||||
If you only want to see the global context use the --global argument (for local use --local, for private use --private):
|
||||
|
||||
$ git ignore
|
||||
Global gitignore: /home/alice/.gitignore
|
||||
|
|
@ -93,34 +131,55 @@ To quickly append a new pattern to the default/local context simply:
|
|||
Adding pattern(s) to: .gitignore
|
||||
... adding '*.log'
|
||||
|
||||
You can now configure any patterns without ever using an editor, with a context and pattern arguments:
|
||||
You can now configure any patterns without ever using an editor (or use a shortcut to open file in editor when needed), 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 '*.tmp'
|
||||
... adding '*.log'
|
||||
... adding 'tmp/*'
|
||||
... adding ''
|
||||
... adding '# Files I'd like to keep'
|
||||
... adding '!work'
|
||||
... adding ''
|
||||
|
||||
|
||||
Local gitignore: .gitignore
|
||||
|
||||
|
||||
# Temporary files
|
||||
index.tmp
|
||||
*.tmp
|
||||
*.log
|
||||
tmp/*
|
||||
|
||||
# Files I'd like to keep
|
||||
!work
|
||||
|
||||
Removing patterns works in a similar way. Select context and pass patterns to be removed from the gitignore file.
|
||||
|
||||
$ git ignore -l -r "*.log"
|
||||
Removing patterns from local gitignore: .gitignore
|
||||
... removing '*.log'
|
||||
|
||||
Local gitignore: .gitignore
|
||||
|
||||
# Temporary files
|
||||
*.tmp
|
||||
tmp/*
|
||||
|
||||
# Files I'd like to keep
|
||||
!work
|
||||
|
||||
If you want to open gitignore in an editor and do changes manually pass -e flag:
|
||||
|
||||
$ git ignore -p -e
|
||||
|
||||
|
||||
## AUTHOR
|
||||
|
||||
Written by Tj Holowaychuk <<tj@vision-media.ca>> and Tema Bolshakov <<tweekane@gmail.com>>
|
||||
and Nick Lombard <<github@jigsoft.co.za>>
|
||||
and Nick Lombard <<github@jigsoft.co.za>> and Kirill Dergachev <<kdergachev1062@gmail.com>>
|
||||
|
||||
## REPORTING BUGS
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue