Repository history rewrite
Goal
Optimize clone/fetch performance by flattening repository history and reducing historical object payload while preserving maintainer attribution.
Chosen Flattening Mode
- Mode: single-commit snapshot (maximum pack-size reduction)
- Why: this repository contains large historical binary artifacts; flattening to a single root commit yields the largest transfer reduction.
- Maintainer preservation strategy: preserve full pre-flatten attribution in the unlisted maintainer history manifest.
Pre-Cutover Inputs
- Ensure full history is present (
git fetch --unshallow originwhen required). - Generate baseline artifacts and manifest:
scripts/maintenance/flatten-history.sh
- Review baseline files in
/tmp/shaft-history-rewrite/:pre-maintainers-shortlog.txtpre-identities-raw.txtpre-largest-blobs.txtpre-count-objects.txtpre-dotgit-size.txt
Retention / Removal Policy
- Retain: current
maintree content needed for build/test/runtime/docs. - Remove from history: all prior commit graph and unreachable historical blobs.
- Result: new history starts from one fresh root commit, with maintainer attribution preserved in manifest.
Execute Local Rewrite
TARGET_BRANCH=main \
FLATTEN_BRANCH=history/flattened-main \
scripts/maintenance/flatten-history.sh --execute
The script auto-configures a local fallback git identity when
user.name/user.emailare not set. You can override rewrite commit identity explicitly withGIT_AUTHOR_NAME,GIT_AUTHOR_EMAIL,GIT_COMMITTER_NAME, andGIT_COMMITTER_EMAIL.
Validation Checklist
- Maintainer manifest is published in the documentation archive.
- Object/pack improvement:
git count-objects -vHdu -sh .git
- Clone benchmark (same runner, no local hardlink optimization):
/usr/bin/time -f '%E real' git clone --no-local <repo-url> /tmp/clone-baseline/usr/bin/time -f '%E real' git clone --no-local <rewritten-repo-url> /tmp/clone-rewritten
- Ref/tag integrity review completed (release tags preserved only if intentionally recreated).
- Example measured results are retained in the history rewrite validation record.
Maintainer Cutover Procedure (Force Push)
- Announce maintenance window and temporary push freeze.
- Create remote backup mirror before cutover:
Replacegit clone --mirror <repo-url> /tmp/repo-backup-mirror.git
<repo-url>with the full repository URL, for example:https://github.com/ShaftHQ/SHAFT_ENGINE.git. - Push rewritten branch to a staging remote for verification.
- After approval, force-update protected default branch (maintainer operation only).
- Broadcast migration instructions to contributors:
git fetch --all --prunegit switch maingit reset --hard origin/maingit gc --prune=now
Rollback Plan
- Keep backup mirror and pre-flatten backup ref until stability checks complete.
- If rollback is required, force-push backup mirror/ref back to default branch.
- Re-run post-rollback verification (tags, CI pipelines, release automation).