Skip to content

Commit

Permalink
add FAQ/git docs on partial clone to reduce repo size (#126)
Browse files Browse the repository at this point in the history
* add FAQ/git docs on partial clone to reduce repo size

* consolidate FAQ dir
  • Loading branch information
tonymet committed Mar 1, 2024
1 parent 6ab4670 commit f7cf3f8
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/faqs.md → docs/FAQ/faqs.md
Expand Up @@ -103,3 +103,14 @@ to "pay" for listing. Here's how:

^ This will add 1000 credits to your account. But you know, you can't really buy
anything with it :D

## How Can I Reduce the Size of My Clones
`forem` clones are currently 1.5G due to old vendor/cache gem's committed to the
git repo. Use the steps below to reduce your clone size by 80% -- meaning
faster _clone_ , deploy , _log_ and less disk usage

```
# do a partial clone
$ git clone --single-branch --branch main --filter=blob:none git@github.com:forem/forem.git
```
see [Advanced Git FAQ](./git/) for more details and docs.
41 changes: 41 additions & 0 deletions docs/FAQ/git.md
@@ -0,0 +1,41 @@
# Reducing Git Repo Size
`forem` clones are currently 1.5G due to old vendor/cache gem's committed to the
git repo. Use the steps below to reduce your clone size by 80% -- meaning
faster _clone_ , deploy , _log_ and less disk usage

**caveat**: This uses a "partial clone" method which fetches a complete working
tree but avoids cloning older objects from the history . See
[this guide](https://about.gitlab.com/blog/2019/03/13/partial-clone-for-massive-repositories/)
and the [git docs on partial clones](https://git-scm.com/docs/partial-clone) for a
more complete command and config overview.

## Preferred Method for New Clones
```
# do a partial clone
$ git clone --single-branch --branch main --filter=blob:none git@github.com:forem/forem.git
```
### Test to Confirm the Repo Size
```
# your repo will be about 300MB instead of 1500MB
$ du -sh .
280M .
```

## Existing Clones (for experts)
You can clean up existing clones, but with this method you will have to rebase
any changes before submitting PRs. Added work will be required.

#### 1. Update the ref config in `.git/config`
update `fetch` and `partialCloneFilter`
```
[remote "upstream"]
url = git@github.com:forem/forem.git
fetch = +refs/heads/main:refs/remotes/upstream/main
promisor = true
partialclonefilter = blob:none
```
#### 2. Prune Old Objects Out of your Clone
Prerequisite: [git-filter-repo](https://github.com/newren/git-filter-repo) needs to be installed
```
git filter-repo --force --invert-paths --path-glob 'vendor/cache'
```

0 comments on commit f7cf3f8

Please sign in to comment.