Skip to content

Commit 37df8ea

Browse files
Carl Brasicvgrldavidstaheli
authored
Add gitattributes override feature to finding-files-on-github (#29151)
Co-authored-by: Vanessa <vgrl@github.com> Co-authored-by: David Staheli <1767415+davidstaheli@users.noreply.github.com>
1 parent 012525e commit 37df8ea

2 files changed

Lines changed: 43 additions & 2 deletions

File tree

content/search-github/searching-on-github/finding-files-on-github.md

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,52 @@ topics:
1717

1818
**Tips:**
1919

20-
- File finder results exclude some directories like `build`, `log`, `tmp`, and `vendor`. To search for files within these directories, use the [`filename` code search qualifier](/search-github/searching-on-github/searching-code#search-by-filename).
20+
- By default, file finder results exclude some directories like `build`, `log`, `tmp`, and `vendor`. To search for files in these directories, use the [`filename` code search qualifier](/search-github/searching-on-github/searching-code#search-by-filename).{% ifversion file-finder-exclusion-controls %} Alternatively, you can customize which directories are excluded by default [using a `.gitattributes` file](#customizing-excluded-files).{% endif %}
2121
- You can also open the file finder by pressing `t` on your keyboard. For more information, see "[Keyboard shortcuts](/articles/keyboard-shortcuts)."
2222

2323
{% endtip %}
2424

25+
## Using the file finder
26+
2527
{% data reusables.repositories.navigate-to-repo %}
2628
2. Above the list of files, click **Go to file**.
2729
![Find file button](/assets/images/help/search/find-file-button.png)
2830
3. In the search field, type the name of the file you'd like to find.
2931
![Find file search field](/assets/images/help/search/find-file-search-field.png)
3032
4. In the list of results, click the file you wanted to find.
3133

34+
{% ifversion file-finder-exclusion-controls %}
35+
36+
## Customizing excluded files
37+
38+
By default, file finder results do not include files in the following directories if they exist at your repository root:
39+
40+
- `.git`
41+
- `.hg`
42+
- `.sass-cache`
43+
- `.svn`
44+
- `build`
45+
- `dot_git`
46+
- `log`
47+
- `tmp`
48+
- `vendor`
49+
50+
You can override these default exclusions using a `.gitattributes` file.
51+
52+
To do this, create or update a file called `.gitattributes` in your repository root, setting the [`linguist-generated`](https://github.com/github/linguist/blob/master/docs/overrides.md) attribute to `false` for each directory that should be included in file finder results.
53+
54+
For example, the following `.gitattributes` file would cause files in the `build/` directory to be available to the file finder:
55+
56+
```
57+
build/** linguist-generated=false
58+
```
59+
60+
Note that this override requires the use of the recursive glob pattern (`**`). For more information, see "[pattern format](https://git-scm.com/docs/gitignore#_pattern_format)" in the Git documentation. More complex overrides of subdirectories within excluded-by-default directories are not supported.
61+
62+
{% endif %}
63+
3264
## Further reading
3365

34-
- "[About searching on GitHub](/search-github/getting-started-with-searching-on-github/about-searching-on-github)"
66+
- "[About searching on GitHub](/search-github/getting-started-with-searching-on-github/about-searching-on-github)"{% ifversion file-finder-exclusion-controls %}
67+
- "[Customizing how changed files appear on GitHub](/repositories/working-with-files/managing-files/customizing-how-changed-files-appear-on-github)"
68+
- [`.gitattributes`](https://git-scm.com/docs/gitattributes) in the Git documentation{% endif %}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Reference: Issue #7579 - Improved file finder exclusion controls
2+
3+
versions:
4+
fpt: '*'
5+
ghec: '*'
6+
ghes: '>=3.7'
7+
ghae: 'issue-7579'

0 commit comments

Comments
 (0)