Skip to content

Commit f7cf3f8

Browse files
authored
add FAQ/git docs on partial clone to reduce repo size (#126)
* add FAQ/git docs on partial clone to reduce repo size * consolidate FAQ dir
1 parent 6ab4670 commit f7cf3f8

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed

docs/faqs.md renamed to docs/FAQ/faqs.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,14 @@ to "pay" for listing. Here's how:
103103

104104
^ This will add 1000 credits to your account. But you know, you can't really buy
105105
anything with it :D
106+
107+
## How Can I Reduce the Size of My Clones
108+
`forem` clones are currently 1.5G due to old vendor/cache gem's committed to the
109+
git repo. Use the steps below to reduce your clone size by 80% -- meaning
110+
faster _clone_ , deploy , _log_ and less disk usage
111+
112+
```
113+
# do a partial clone
114+
$ git clone --single-branch --branch main --filter=blob:none git@github.com:forem/forem.git
115+
```
116+
see [Advanced Git FAQ](./git/) for more details and docs.

docs/FAQ/git.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Reducing Git Repo Size
2+
`forem` clones are currently 1.5G due to old vendor/cache gem's committed to the
3+
git repo. Use the steps below to reduce your clone size by 80% -- meaning
4+
faster _clone_ , deploy , _log_ and less disk usage
5+
6+
**caveat**: This uses a "partial clone" method which fetches a complete working
7+
tree but avoids cloning older objects from the history . See
8+
[this guide](https://about.gitlab.com/blog/2019/03/13/partial-clone-for-massive-repositories/)
9+
and the [git docs on partial clones](https://git-scm.com/docs/partial-clone) for a
10+
more complete command and config overview.
11+
12+
## Preferred Method for New Clones
13+
```
14+
# do a partial clone
15+
$ git clone --single-branch --branch main --filter=blob:none git@github.com:forem/forem.git
16+
```
17+
### Test to Confirm the Repo Size
18+
```
19+
# your repo will be about 300MB instead of 1500MB
20+
$ du -sh .
21+
280M .
22+
```
23+
24+
## Existing Clones (for experts)
25+
You can clean up existing clones, but with this method you will have to rebase
26+
any changes before submitting PRs. Added work will be required.
27+
28+
#### 1. Update the ref config in `.git/config`
29+
update `fetch` and `partialCloneFilter`
30+
```
31+
[remote "upstream"]
32+
url = git@github.com:forem/forem.git
33+
fetch = +refs/heads/main:refs/remotes/upstream/main
34+
promisor = true
35+
partialclonefilter = blob:none
36+
```
37+
#### 2. Prune Old Objects Out of your Clone
38+
Prerequisite: [git-filter-repo](https://github.com/newren/git-filter-repo) needs to be installed
39+
```
40+
git filter-repo --force --invert-paths --path-glob 'vendor/cache'
41+
```

0 commit comments

Comments
 (0)