Inspection
Revision tree and ZIP export
6 min read
The tree shows every file and folder of a revision (commit, branch or tag), not just the changed ones. You can open any file from that version with syntax highlighting, see its history and blame, and save a copy, without a checkout and without touching the working directory.
Use the tree to check what a configuration file looked like in an old tag, look for a file that was deleted later, or pick up a file from another branch for reference.
- A commit's menu: Browse the files of this commit.
- Menu of a branch (local or remote) or of a tag: Browse the files of <name>.
- Right panel, in a commit's details: View all files button ("Opens the full tree of this revision: every file, not only the changed ones").
- Blame: right-click a block › Browse the tree of this version, which opens the file right away.
- Treemap: right-click an item › Show in the revision tree.
- Insights, with a folder or file in focus: Open in tree button.
- Palette (Ctrl+P):
- "Browse the files of <current branch>" ("The revision tree, with the content, history and blame of each file");
- "Browse the files of a revision…", which asks for the Revision ("A branch name, a tag or a commit SHA.") and opens it with Open.
- Right-click the
v1.4.0tag and choose Browse the files of v1.4.0. - The tree opens in the central area. The header shows the revision and the commit's author and date.
- Browse the folders with the mouse or the keyboard (arrows to open and close folders).
- To find a file, type part of its name in Find a file by name. The list shows how many were found.
- Click a file to see its content on the right, with the name and the size. In a Markdown file, switch between Preview and Code.
- Use the file's buttons:
- File history ("Commits that changed this file up to this revision");
- Blame ("Who wrote each line in this revision");
- Save as… (icon), which writes the file from that version wherever you choose.
- Right-click a line of the content for Investigate the origin of line N… or Blame this version.
- To see another revision, use Change revision…. To go to the commit, Go to commit ("Closes the tree and shows the commit in the graph"). To close, the X or Esc.
Right-click a folder:
| Item | What it does |
|---|---|
| Export this folder as ZIP… | Opens the export with the folder already chosen. |
| Contributors of this folder | Opens the insights for that folder only. |
| Activity of this folder | Opens the activity over time for that folder only. |
| Folder history | Opens the folder history: the commits that touched anything inside it up to this revision, with only the folder's files in each commit. |
Right-click a file:
| Item | What it does |
|---|---|
| Open | Shows the content on the right. |
| File history | Opens the file history up to this revision. |
| Blame | Opens the blame at this revision. Only for regular files. |
| Visual history of this file | Opens the activity over time for this file only. |
| Save as… | Saves the file from this revision. Disabled for submodules. |
The tree only reads git objects; the working directory isn't touched:
git ls-tree -z -l <revision>:<folder> # contents of a folder, with sizes
git ls-tree -r -z --name-only <revision> # every path, for the search by name
git cat-file blob <revision>:<file> # contents of a file (also for Save as…)
Nothing to undo: the tree doesn't change the repository. Save as… only creates the file you chose.
- "Pick a file in the tree to see its content in this revision.": no file is open yet.
- "Binary file: the content isn't shown.": use Save as… to get the file. Images are shown.
- "File too large to show here.": text above 4 MB (and images above 12 MB) doesn't appear on screen, but can be saved.
- "Submodule: in this revision it points to commit <sha>.": the entry is a submodule. See Submodules.
- "Git LFS file: the repository only stores the pointer below; the content lives on the LFS server.": the tree shows the pointer, not the content. See Git LFS.
- "Symbolic link to <target>": the entry is a symlink; it appears with the link badge.
- "Empty file.": the file exists, but has no content.
- "The first N files found (refine the search)": the search stops at 300 results.
- "No file with that name in this revision": no path contains the text you typed.
- "File saved to <path> (<size>).": confirmation of Save as….
- "The file "<path>" doesn't exist in revision <sha>." and ""<path>" isn't a folder in this revision.": the requested path doesn't exist in that revision.
- "The repository has no commits yet": the palette makes the command unavailable.
Creates a compressed file with the content of a revision, or of one of its folders, without the git history. It's useful for handing a version's code to someone who doesn't use git, attaching it to a ticket, or keeping a copy of a release.
- A commit's menu: Export this commit as ZIP…
- Menu of a branch or of a tag: Export <name> as ZIP…
- Revision tree: Export ZIP… button in the header, or right-click a folder › Export this folder as ZIP….
- Palette (Ctrl+P): "Export <current branch> as ZIP…" ("git archive of the whole revision or of a folder (ZIP or tar.gz)").
- Right-click the
v1.4.0tag and choose Export v1.4.0 as ZIP…. - Under Content, choose The whole revision or Only a folder. For a folder, type its
path in the revision, for example
src/lib. - Under Format, choose ZIP or tar.gz.
- Click Choose where to save…. The Save the exported file window suggests the name
<repository>-<revision>[-<folder>].<format>, for exampleloja-v1.4.0.zip. - Follow "Exporting…" with the progress bar ("N of M entries written"). Cancel stops it.
- At the end, the notice "Exported to <path> (<size>, N entries)." has the Show in folder button.
| Option | What it does | Default |
|---|---|---|
| The whole revision | Exports every file in the revision. | Selected (or Only a folder, when opened from a folder) |
| Only a folder | Exports only the folder you entered. | — |
| ZIP / tar.gz | File format. | ZIP; your choice is remembered |
Inside the file, everything goes into a folder named after the repository and the short SHA.
Anything marked export-ignore in .gitattributes is left out.
git archive -v --format=zip --prefix=<repository>-<sha>/ -o <temporary-file> <sha> [-- <folder>]
The file is written under a temporary name next to the destination and only gets the chosen name at the end. That way, canceling or failing midway doesn't leave a half-written ZIP or damage a file that already existed with that name.
Example .gitattributes to leave files out of the export:
.gitlab-ci.yml export-ignore
testes/ export-ignore
The export doesn't change the repository. To undo it, delete the generated file.
- "Export canceled; no file was written.": you canceled. Nothing is left half-done.
- "Choose a valid destination file (full path, in an existing folder): <path>" and "The destination is a folder: <path>": the chosen destination won't work.
- ""<folder>" isn't a folder in this revision.": the Only a folder path doesn't exist in that revision.
- "Couldn't write <path>: <error>": there's no permission or no space at the destination.
The tree and the export have no preference of their own and no company policy key.
- File history
- Blame
- Repository insights
- Treemap
- Git documentation: git archive (opens another site)