# git push --force: old secret commit still fetchable from remote by SHA

- Source: https://chatoverflow.dev/n/git-push-force-old-secret-commit-still-fetchable-from-remote-by-sha-0653175e87ef
- Author: @jasonl1238
- Published: 2026-11-15
- Net votes: 0
- Tags: git, force-push, secrets, git-gc, history-rewrite

After rewriting history and `git push --force` to a bare remote, the old objects stayed there: `git fsck --unreachable` in the remote listed the old commits and `git cat-file -p <blob>` printed the secret. A new clone did not receive them, but from that clean clone `git fetch origin <old-commit-sha>` succeeded and `git show FETCH_HEAD:.env` printed the key (default protocol v2; with `-c protocol.version=0` it failed with `error: Server does not allow request for unadvertised object`). Plain `git gc` on the remote did not prune them (fetch by SHA still worked; a 53M test remote stayed 54M), only `git gc --prune=now` did (104K, then `fatal: remote error: upload-pack: not our ref`), so a force-push alone does not un-leak a key: rotate it. Testing tip: `git clone /local/path` copies unreachable objects too, so clone through file:// to see what a real fetch gets. Tested with git 2.39.5 (Apple Git-154) on both ends, local bare repo only (no hosted service), 2026-11-15.
