Skip to content
Source
Sign inSign up

Use the file tree

Code and repositories / Read code

Move through a repository with the file tree

You read code that calls code in other folders, and each time you go up to the repository and down again, you lose your place. The file tree shows every folder and file of the repository next to the code, and it stays there while you move.

4 min read

1. Open a folder or a file

Open a repository, then click a folder or a file in the file list. On a wide screen, the file tree shows on the left of the folder page and the file page.

  • The folders on the path to the current folder or file are open.
  • The current folder or file is highlighted.
The folder page of a repository. The file tree is on the left, and the current folder is open and highlighted.

Note

The home page of a repository has no tree. Open a folder or a file to see it.

2. Move in the tree

  • Click a folder to open its page. The folder opens in the tree.
  • Click the arrow next to a folder to open or close it. You stay on the same page.
  • Click a file to open it.

While a file or folder loads, the current view stays usable, and a progress bar shows at the top.

3. Use the keyboard

Press Tab until a row of the tree has the focus. Then use these keys:

KeyWhat it does
Up, DownMoves to the row above or below
RightOpens a closed folder. On an open folder, moves to its first row.
LeftCloses an open folder. On another row, moves to its parent folder.
EnterOpens the page of the row
Home, EndMoves to the first or the last row

4. Hide or show the tree

Click the Hide file tree button at the right of the toolbar above the code. To get the tree back, click the same button (Show file tree).

This browser remembers your choice for the next pages.

Done

You open folders and files from the tree, and the tree stays next to the code with the folders that you opened. The current folder or file is always highlighted, so you know where you are.

To see an image as a picture, or to step through the commits of a file, see Read a file and its history.

On a phone

The tree is hidden on a narrow screen. Click the file tree button in the toolbar. The tree opens in a panel with the title Files. When you open a folder or a file from the panel, the panel closes.

In a big repository, or when you are not signed in

In a repository with 10,000 files or more, or when you are not signed in, the tree loads only the folders that you need:

  • When a page opens, the tree loads the top folder and the folders on the path to the current folder or file.
  • When you open a folder, the tree loads it. While it loads, a spinner shows in place of its arrow.
  • Each folder shows its first 1,000 entries.
  • Each folder has its own row, also in a chain like src/server/api, where each folder holds only the next one.

If a folder does not load, it stays closed. Open it again to try again. If the top folder does not load, the tree shows The files did not load. Click Try again.

What the tree shows

  • Each row has the same file or folder icon as the file list, so you find a file by its icon.
  • The tree stays on the screen when you move between file pages and folder pages.
  • The tree keeps the folders that you opened and closed, for each repository and branch, in this browser tab. A new page opens the path to its folder or file again.

The tree and the filter

  • With Show only or Hide on, the tree shows the same files as the file list (see Filter the files of a repository).
  • With an Owner on, the tree on a folder page shows only the files of that owner (see Filter by owner).
  • On a file page, the tree uses the last filter of the repository in this browser. There, the owner does not filter the tree.

In a repository with 10,000 files or more, or when you are not signed in, the tree uses the filter like this:

  • Show only and Hide apply to the files that the tree loaded.
  • Every folder stays, unless Hide names it.
  • The owner does not filter the tree.