Skip to content

Commit bd28f1d

Browse files
authored
[Docs] Clone filters (#14555)
In summary: set uploadpack.allowfilter Signed-off-by: Bagas Sanjaya <[email protected]>
1 parent 9b6ff81 commit bd28f1d

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
---
2+
date: "2021-02-02"
3+
title: "Clone filters (partial clone)"
4+
slug: "clone-filters"
5+
weight: 25
6+
draft: false
7+
toc: false
8+
menu:
9+
sidebar:
10+
parent: "advanced"
11+
name: "Clone filters"
12+
weight: 25
13+
identifier: "clone-filters"
14+
---
15+
16+
# Clone filters (partial clone)
17+
18+
Git introduces `--filter` option to `git clone` command, which filters out
19+
large files and objects (such as blobs) to create partial clone of a repo.
20+
Clone filters are especially useful for large repo and/or metered connection,
21+
where full clone (without `--filter`) can be expensive (as all history data
22+
must be downloaded).
23+
24+
This requires Git version 2.22 or later, both on the Gitea server and on the
25+
client. For clone filters to work properly, make sure that Git version
26+
on the client is at least the same as on the server (or later). Login to
27+
Gitea server as admin and head to Site Administration -> Configuration to
28+
see Git version of the server.
29+
30+
By default, clone filters are disabled, which cause the server to ignore
31+
`--filter` option.
32+
33+
To enable clone filters on per-repo basis, edit the repo's `config` on
34+
repository location. Consult `ROOT` option on `repository` section of
35+
Gitea configuration (`app.ini`) for the exact location. For example, to
36+
enable clone filters for `some-repo`, edit
37+
`/var/gitea/data/gitea-repositories/some-user/some-repo.git/config` and add:
38+
39+
```ini
40+
[uploadpack]
41+
allowfilter = true
42+
```
43+
44+
To enable clone filters globally, add that config above to `~/.gitconfig`
45+
of user that run Gitea (for example `git`).
46+
47+
Alternatively, you can use `git config` to set the option.
48+
49+
To enable for a specific repo:
50+
51+
```bash
52+
cd /var/gitea/data/gitea-repositories/some-user/some-repo.git
53+
git config --local uploadpack.allowfilter true
54+
```
55+
To enable globally, login as user that run Gitea and:
56+
57+
```bash
58+
git config --global uploadpack.allowfilter true
59+
```
60+
61+
See [GitHub blog post: Get up to speed with partial clone](https://github.blog/2020-12-21-get-up-to-speed-with-partial-clone-and-shallow-clone/)
62+
for common use cases of clone filters (blobless and treeless clones), and
63+
[Gitlab docs for partial clone](https://docs.gitlab.com/ee/topics/git/partial_clone.html)
64+
for more advanced use cases (such as filter by file size and remove
65+
filters to turn partial clone into full clone).

0 commit comments

Comments
 (0)