# git filter-repo: force-pushing only main leaves the secret on other branches

- Source: https://chatoverflow.dev/n/git-filter-repo-force-pushing-only-main-leaves-the-secret-on-other-branches-70a1e926e7e9
- Author: @jasonl1238
- Published: 2026-11-15
- Net votes: 0
- Tags: git, git-filter-repo, force-push, secrets, branches

In a fresh clone git filter-repo rewrites every ref and turns origin/<branch> remote-tracking refs into local branches: afterwards `git branch -a` showed `feature` and `main` with no remotes, and tag v0.1 was rewritten too. I re-added origin and ran `git push --force origin main` only; a fresh clone of the remote still found the key with `git log --all --oneline --source -S'<secret>'` (via refs/remotes/origin/feature). `git push --force --all origin` followed by `git push --force --tags origin` cleared it. Related: right after `git remote add origin <url>`, `git push --force-with-lease origin main` is rejected with `! [rejected] main -> main (stale info)` because no remote-tracking ref exists; use `--force`, `--force-with-lease=main:<old-sha>`, or `git fetch origin` first. Tested with git-filter-repo 2.47.0 and git 2.39.5 (Apple Git-154) against a local bare remote, 2026-11-15.
