Exclude files from pull request diffs
Only repository administrators can add files to be excluded from the diff view.
The pull request view shows each file modified in the pull request. You can exclude files from appearing in the diff view of a pull request by specifying patterns in the 'Excluded files' repository setting page.
To exclude certain files from appearing in pull requests:
In the repository containing the pull request, click Repository settings > Excluded files in the Pull Requests section.
In the Patterns field, enter patterns to exclude from pull request diff views.
Click Save.
Each line you add to the Patterns field specifies a pattern to exclude.
A pattern can be:
a filename (e.g.
index.min.js
).a path relative to the repository root (e.g.
/minified/index.min.js
).a pattern including wildcards (e.g.
*.min.js
or/minified/**
).
Files that match any pattern entered will still appear in the file tree and in the list of files changed for a pull request, but the changed content of those excluded files won't appear in the diff view.
Excluded files pattern format
The excluded files repository setting format is similar to the .gitignore pattern format with two notable exceptions:
Trailing spaces are not allowed.
There is no way to negate a pattern.
Important details
Matching is case-insensitive.
Directories are indicated by a forward slash "
/
".Backslash "
\
" is used to escape special characters.Non-ASCII characters are supported. UTF-8 encoding is assumed.
Example
# package manager lock files (at the repository root)
/Gemfile.lock
/package-lock.json
# minified JS and CSS (anywhere in the repository)
*.min.js
*.min.css
# third-party libraries
/vendor/**
# generated XML (inside any my-code-generator/ directory)
my-code-generator/*.xml
# text files from November 2017
notes/2017-11-[0-3][0-9].txt
Blank lines and comments
File patterns can be organized with blank lines and comments. Each non-blank line can contain either a pattern or a comment, not both.
Pattern | Matches | Notes |
---|---|---|
| Nothing | Blank lines can be used as separators. |
| Nothing | Any line beginning with |
Filename
A file or files can be excluded by filename. If a filename contains special characters, those characters must be escaped with backslashes.
To exclude a single, specific file, start your pattern with "
/
" which returns matches relative to the root of the repository.To exclude every file that matches a filename, do not add the leading "
/
".
Pattern | Matches | Notes |
---|---|---|
|
| A single file named |
|
| Any file named |
|
| A single file named |
|
| Any file named |
|
| Any file named |
Directory name
A pattern ending with "/
" matches files contained in that directory.
Pattern | Matches | Notes |
---|---|---|
|
| Any file in a directory named |
|
| Any file in a directory named |
|
| Any file in a directory named |
Wildcards
[]
wildcard
The []
wildcard matches one character in a selected range or character class.
Pattern | Matches | Notes |
---|---|---|
|
|
|
|
|
|
|
|
|
|
|
Note: A right bracket " |
|
| Non-ASCII characters are supported. |
?
wildcard
The ?
wildcard matches any single character except "/
".
Pattern | Matches | Notes |
---|---|---|
|
| Non-ASCII characters are supported. |
*
wildcard
The *
wildcard matches anything except "/
".
Pattern | Matches | Notes |
---|---|---|
|
|
|
|
|
|
|
|
|
**
wildcard
The **
wildcard matches anything in the path name including nested directories. Using more than two consecutive **
results in an invalid pattern that matches nothing.
Pattern | Matches | Notes |
---|---|---|
|
| Same as |
|
| A trailing |
|
|
|
|
|
|
Was this helpful?