Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add FAQ/git docs on partial clone to reduce repo size #126

Merged
merged 2 commits into from
Mar 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/faqs.md → docs/FAQ/faqs.md
Original file line number Diff line number Diff line change
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 [email protected]:forem/forem.git
```
see [Advanced Git FAQ](./git/) for more details and docs.
41 changes: 41 additions & 0 deletions docs/FAQ/git.md
Original file line number Diff line number Diff line change
@@ -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 [email protected]: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 = [email protected]: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'
```
Loading