Repository
Shallow clone and partial clone
3 min read
Large repositories take a long time to clone. Git has two ways to download less:
- Shallow clone: downloads only the most recent commits. The graph ends where the local history does.
- Partial clone: downloads the whole history, but the contents of old files only when they're needed.
Versora creates both types through the clone's advanced options and shows in the repository bar when a repository is shallow or partial. In a shallow repository, the bar offers to download more history.
The Clone repository window is described in Open, clone and create repositories. This section explains only the Advanced options (the title gets "changed" when any of them is on).
| Option | What it does | Command | Default |
|---|---|---|---|
| Shallow clone — only the last N commits | Downloads only the N most recent commits. "Faster and smaller. The rest of the history can be downloaded later from the "Shallow clone" bar." | git clone --depth=N | Off (N = 1 when on) |
| Branch (optional) | Branch to download and leave checked out. | git clone --branch <branch> | Empty: the remote default |
| Download only this branch | The remote's other branches aren't downloaded. | git clone --single-branch | Off |
| Also clone submodules | Clones and initializes the submodules along with it. | git clone --recurse-submodules | Off |
| Partial clone — file contents on demand | The full history is downloaded, but the contents of old files are fetched only when needed. | git clone --filter=blob:none | Off |
With shallow clone on and Download only this branch off, the app adds --no-single-branch:
without it, --depth alone would already limit the clone to one branch.
Caution
Partial clone requires a server that supports filters (recent GitHub, GitLab and Gitea). In a partial repository, viewing files from old commits requires a connection to the server.
In a shallow repository, the repository bar shows Shallow clone (tooltip "Shallow clone: only the most recent commits were downloaded. The graph ends where the local history does.") with two buttons.
Repository bar: Fetch more history… and Fetch full history.
- To download just a little more, click Fetch more history…. The Fetch more history window asks how many more commits to download, starting where the history ends. The Additional commits field comes with 50.
- Click Fetch. The notice says "Fetched 50 more commits of history".
- To download everything at once, click Fetch full history. The repository is no longer shallow ("Full history downloaded") and the bar goes away.
git fetch --deepen=50
git fetch --unshallow
Downloading more history doesn't change local branches or files, and it isn't part of Ctrl+Z. There's no way to make the repository shallow again from the app: for that, clone again with the shallow clone option.
- "Enter a whole number of commits, 1 or more."
- "This repository already has the full history.": there's nothing to download.
- Network and credential errors appear as in any other fetch: see Fetch.
In a partial repository, the bar shows Partial clone (tooltip "Partial clone (filter ‹filter›): file contents are downloaded from the remote when needed. Some operations need a network connection."). There's no action: the bar only reminds you that some operations need a connection to the server, such as viewing files from old commits.
To turn a complete repository into a partial one, you have to clone again, into a new folder. The Optimize repository screen suggests this for repositories with a very large history and has the Clone with options… button.
There's no setting of its own.
- Sparse checkout
- Optimize repository
- Official documentation: git clone (opens another site) and partial clone (opens another site)