Skip to content
Source
Sign inSign up

Filter the files

Code and repositories / Read code

Filter the files of a repository

A big folder has many files, and you want to see only the .ts files, or hide the dot folders like .github and .vscode. The Filter button above the file list shows only the names that you want, so you find the code faster.

4 min read

1. Open the filter

Open a repository, or a folder in it. Above the file list, click Filter.

2. Type your patterns

  • Show only: the file names to show, for example *.ts. A folder stays when a file below it matches.
  • Hide: the file and folder names to hide, for example .*/, node_modules/.

Put commas between the patterns. Then click Apply. The list shows only the names that pass.

The Filter popover over the file list, with *.ts in Show only and .*/ in Hide

3. Write a pattern

PatternWhat it matches
*.tsNames that end in .ts
.envNames that contain .env, like .env and .env.local
.*/Folders with a name that starts with a dot (in Hide)
node_modules/Folders with a name that contains node_modules (in Hide)
  • Text without * matches each name that contains it. Uppercase and lowercase are the same.
  • Text with * must match the full name. * matches any text, and uppercase and lowercase are different.
  • A / at the end of a Hide pattern matches folders only.
  • A pattern matches a name, never a path. So src/*.ts matches nothing.

Note

With Show only, a folder stays only when a file below it matches and is not hidden. In a repository with 10,000 files or more, every folder stays, in the file list and in the file tree. When you are not signed in, every folder stays in the file tree, in a repository of any size.

4. Keep or clear the filter

  • The filter is in the URL. When you send the link, the other person sees the same list.
  • The filter stays when you open a folder, or when you change the branch.
  • The file tree next to the code follows the same filter.
  • This browser remembers the last filter of each repository. When the URL has no filter, that filter comes back.
  • To remove the filter, click Filter, then Clear.

Filter by owner

You want to see only the files of one person or one team. Or you want to find the files that nobody owns.

  1. Click Filter.
  2. In Owner, pick a choice from the table below.
  3. Click Apply.
ChoiceWhat shows
AnyoneThe owner does not filter. This is the default.
Any ownerThe files with an expert or a code owner
No ownerThe files with no expert and no code owner
A person, under PeopleThe files of that person
A team, under TeamsThe files of that team
The Filter popover with the Owner field above Show only and Hide. Owner shows Anyone, and its description says People and teams from Experts and CODEOWNERS

With the owner carol, the folder src shows only the folder web, and the file tree shows only the files that carol owns:

The folder src with the owner carol: the list shows only web, the file tree shows docs, src/web and package.json, and the Filter button shows 1

The owner works together with Show only and Hide. A folder stays only when a file below it passes. The URL keeps the owner: ?owner=ana, ?owner=@acme/core, ?owner=:any or ?owner=:none.

Note

In a repository with 10,000 files or more, the owner does not filter the file list or the file tree. When you are not signed in, the owner does not filter the file tree, in a repository of any size.

Who owns a file

  • A person owns the files of their expert entry, and the files whose CODEOWNERS rule names them. A rule that names their team does not count. To see those files, pick the team.
  • A team owns the files whose CODEOWNERS rule names the team.
  • The rule of a file is the last rule of the CODEOWNERS file that matches it, on the branch that you see.

Done

The file list shows only the files that you want. The Filter button shows how many filters are on: one for each pattern, and one for the owner.

The folder src with the filter on: only the folder util and the file app.ts show, and the Filter button shows 2

Vault files in the list follow the same filter (see Keep private files out of git). To learn the icons, the faded rows and the folded rows of the list, see Read the file list.