Issue: Repository takes a long time to clone (117MB .git directory)
Root Cause: node_modules and large build artifacts were committed in git history
Impact: Slow clones, wasted bandwidth, poor contributor experience
.git directory: 117 MB
Pack files: 115 MB
Total objects: 42,964
The following large files are in git history:
backend/node_modules/@swc/core-linux-x64-gnu/swc.linux-x64-gnu.node- 28 MBnode_modules/@prisma/engines/...- 20+ MBbackend/node_modules/typescript/lib/typescript.js- 20 MBnode_modules/@electric-sql/pglite/dist/pglite.wasm- 9 MB- Multiple Prisma WASM files - 4-5 MB each
- Various other node_modules files
- Date: March 25, 2026
- Commit: 8dcc4b43 "fit: delete node_modules from github"
- Issue: node_modules were committed, then deleted, but remain in history
Pros:
- Fast and efficient
- Specifically designed for this purpose
- Safer than git filter-branch
- Easy to use
Cons:
- Requires Java
- Rewrites history (requires force push)
- All contributors need to re-clone
Steps:
-
Install BFG Repo-Cleaner
# macOS brew install bfg # Or download from: https://rtyley.github.io/bfg-repo-cleaner/
-
Create a fresh clone
git clone --mirror https://github.com/your-org/Nestera.git cd Nestera.git -
Run BFG to remove node_modules
bfg --delete-folders node_modules bfg --delete-folders dist bfg --delete-folders target
-
Clean up and push
git reflog expire --expire=now --all git gc --prune=now --aggressive git push --force
-
Verify size reduction
du -sh .
Expected Result: Repository size should drop from 117MB to ~10-20MB
Pros:
- More powerful than BFG
- Better maintained
- Official Git recommendation
Cons:
- More complex to use
- Requires Python
- Rewrites history
Steps:
-
Install git-filter-repo
# macOS brew install git-filter-repo # Or: pip install git-filter-repo
-
Create a fresh clone
git clone https://github.com/your-org/Nestera.git cd Nestera -
Remove large directories from history
git filter-repo --path node_modules --invert-paths git filter-repo --path backend/node_modules --invert-paths git filter-repo --path frontend/node_modules --invert-paths git filter-repo --path dist --invert-paths git filter-repo --path backend/dist --invert-paths
-
Force push
git remote add origin https://github.com/your-org/Nestera.git git push --force --all git push --force --tags
Pros:
- No history rewrite needed
- No force push required
- Immediate solution
Cons:
- Doesn't fix the root problem
- Contributors still download full history eventually
- Not a permanent solution
Implementation:
Update README.md with shallow clone instructions:
## Quick Clone (Recommended for Contributors)
For faster cloning, use a shallow clone:
```bash
# Clone with limited history
git clone --depth 1 https://github.com/your-org/Nestera.git
# Or clone only main branch
git clone --single-branch --branch main https://github.com/your-org/Nestera.gitThis reduces clone time from ~2 minutes to ~10 seconds.
---
### Option 4: Start Fresh Repository (Nuclear Option)
**Pros:**
- Completely clean history
- Smallest possible size
- Fresh start
**Cons:**
- Loses all git history
- Loses all issues/PRs (unless migrated)
- Most disruptive option
**Only use if:**
- History is not important
- You want a completely fresh start
- Other options don't work
---
## Recommended Approach
### Step-by-Step Implementation
#### Phase 1: Immediate Fix (Today)
1. **Update .gitignore** to be more comprehensive
2. **Add shallow clone instructions** to README
3. **Document the issue** for contributors
#### Phase 2: Permanent Fix (This Week)
1. **Backup the repository**
```bash
git clone --mirror https://github.com/your-org/Nestera.git Nestera-backup.git
-
Use BFG Repo-Cleaner (recommended)
# Install BFG brew install bfg # Clone mirror git clone --mirror https://github.com/your-org/Nestera.git cd Nestera.git # Remove large directories bfg --delete-folders node_modules bfg --delete-folders dist bfg --delete-folders .next # Clean up git reflog expire --expire=now --all git gc --prune=now --aggressive # Verify size du -sh . # Push (COORDINATE WITH TEAM FIRST!) git push --force
-
Notify all contributors
- Send announcement about history rewrite
- Provide re-clone instructions
- Set a specific date/time for the change
-
All contributors must re-clone
cd .. rm -rf Nestera git clone https://github.com/your-org/Nestera.git -
Verify the fix
cd Nestera du -sh .git # Should be ~10-20MB instead of 117MB
-
Update documentation
- Remove shallow clone workaround
- Add note about the cleanup
- Update CONTRIBUTING.md
Here's a comprehensive .gitignore to prevent this in the future:
# Dependencies
node_modules/
**/node_modules/
.pnp
.pnp.js
# Build outputs
dist/
build/
**/dist/
**/build/
.next/
out/
# Rust
target/
**/target/
Cargo.lock
# Testing
coverage/
.nyc_output/
*.log
# Environment
.env
.env.local
.env.*.local
*.env
# IDEs
.vscode/
.idea/
*.swp
*.swo
*~
.DS_Store
# Soroban/Stellar
.soroban/
.stellar/
# Database
*.db
*.sqlite
*.sqlite3
# Prisma
generated/prisma/
# Temporary files
*.tmp
*.temp
.cache/
.temp/
# OS
Thumbs.db
.DS_Store
# Logs
logs/
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
# Test snapshots (if not needed)
test_snapshots/
**/test_snapshots/
# Agent files
.agent/
.agents/
issue.md
# Documentation drafts
PR_DESCRIPTION*.md# Important: Repository Cleanup Scheduled
**What:** We're cleaning up the git repository to improve clone speed
**When:** [DATE] at [TIME]
**Impact:** All contributors must re-clone the repository
**Duration:** ~30 minutes downtime
## Why?
Our repository has grown to 117MB due to accidentally committed node_modules.
This makes cloning slow and wastes bandwidth.
## What's Changing?
- Repository size: 117MB → ~15MB (87% reduction)
- Clone time: ~2 minutes → ~10 seconds
- Git history will be rewritten (force push)
## What You Need to Do
### Before the cleanup:
1. Commit and push all your work
2. Note your current branch names
3. Backup any local-only branches
### After the cleanup:
1. Delete your local repository
```bash
cd ..
rm -rf Nestera-
Clone fresh
git clone https://github.com/your-org/Nestera.git cd Nestera -
Recreate your branches if needed
Reply to this message or check CLONE_SPEED_FIX.md
---
## Testing the Fix
### Before Cleanup
```bash
# Test current clone speed
time git clone https://github.com/your-org/Nestera.git test-before
du -sh test-before/.git
# Expected: 117MB, ~2 minutes
# Test new clone speed
time git clone https://github.com/your-org/Nestera.git test-after
du -sh test-after/.git
# Expected: ~15MB, ~10 secondsTo prevent this from happening again:
- Update .gitignore with comprehensive rules
- Add pre-commit hook to check for large files
- Enable GitHub's large file detection
- Document proper git practices in CONTRIBUTING.md
- Set up CI check for accidentally committed dependencies
- Regular repository size monitoring
Create .git/hooks/pre-commit:
#!/bin/bash
# Check for large files
large_files=$(git diff --cached --name-only | xargs -I {} du -k {} 2>/dev/null | awk '$1 > 1024 {print $2}')
if [ -n "$large_files" ]; then
echo "Error: Large files detected (>1MB):"
echo "$large_files"
echo ""
echo "Please don't commit large files. Use .gitignore or Git LFS."
exit 1
fi
# Check for node_modules
if git diff --cached --name-only | grep -q "node_modules"; then
echo "Error: Attempting to commit node_modules!"
echo "Please add node_modules to .gitignore"
exit 1
fi
exit 0Make it executable:
chmod +x .git/hooks/pre-commit- Repository size: 117 MB
- Clone time: ~2 minutes
- Bandwidth: 117 MB download
- Contributor complaints: Yes
- Repository size: ~15 MB (87% reduction)
- Clone time: ~10 seconds (92% faster)
- Bandwidth: ~15 MB download
- Contributor complaints: None
If something goes wrong:
-
Restore from backup
cd Nestera-backup.git git push --mirror https://github.com/your-org/Nestera.git -
Notify team immediately
-
Investigate what went wrong
-
Try again with more testing
- Identify the problem
- Update .gitignore
- Add shallow clone instructions to README
- Create this documentation
- Schedule cleanup with team
- Create backup
- Run BFG Repo-Cleaner
- Test the cleanup
- Force push (coordinated)
- Verify all contributors re-cloned
- Monitor for issues
- Update documentation
- Add prevention measures
- BFG Repo-Cleaner
- git-filter-repo
- GitHub: Removing sensitive data
- Git LFS (for legitimate large files)
Status: Ready to implement
Priority: High (affects all contributors)
Risk: Medium (requires force push)
Benefit: 87% size reduction, 92% faster clones
Next Steps:
- Review this document with the team
- Schedule the cleanup
- Follow the recommended approach
- Communicate with all contributors