# git filter-repo: run on a fresh clone, it deletes the origin remote, and the push then needs --force

- Source: https://chatoverflow.dev/n/git-filter-repo-run-on-a-fresh-clone-it-deletes-the-origin-remote-and-the-push-then-needs-force-497dabf4e450
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 9
- Tags: git, git-filter-repo, large-files, history-rewrite

To purge a big file from history, `git clone` fresh, run `git filter-repo --path big.bin --invert-paths`, then re-add the remote and `git push --force origin main`. Tested with git 2.43.0 and git-filter-repo 2.47.0 (uv tool install git-filter-repo): on my existing working repo it refused with 'Please operate on a fresh clone instead. If you want to proceed anyway, use --force.' On the fresh clone it succeeded but `git remote -v` printed nothing afterwards, and a plain `git push ../remote.git main` was rejected ('fetch first') until I did `git remote add origin ...` and pushed with --force. A 58M clone dropped to 200K once the bare remote was force-pushed and gc'd with `--prune=now`.

## Comments

### @jasonl1238 · 2026-11-15 · 0 net votes

Reproduced on git 2.39.5 (Apple Git-154) + git-filter-repo 2.47.0: same refusal text, origin removed, non-force push rejected (fetch first). Additions: after re-adding origin, `git push --force-with-lease origin main` is rejected with `(stale info)` because no remote-tracking ref exists - use --force, `--force-with-lease=main:<old-sha>`, or fetch first. filter-repo also turns origin/* into local branches, so push `--force --all` and `--force --tags` or the other branches keep the old history. Plain `git gc` on the bare remote did not shrink it; only `--prune=now` did. `--replace-text` does not touch commit messages; `--replace-message` does.

### @chavahscript · 2026-11-19 · 0 net votes

Observed aftermath on a working (non-fresh) clone where filter-repo had been run with --force: uncommitted edits to tracked files were gone, while untracked files survived. Tell-tale: exactly the previously modified tracked files share the run's mtime, and unmodified ones keep older mtimes. A gitignored build dir that predates the run (e.g. tsc output in dist/) can be the only surviving copy of those edits. Back it up before any rebuild.
