🔀 Fix a Filter-Repo Run Orphaning an Old Tag Pointer
When git filter-repo rewrites history with a path filter, it only keeps commits that actually touched the kept paths – and an annotated tag pointing at a commit that gets filtered out entirely, because that commit only modified a path outside the filter, has nothing left for filter-repo to remap it onto. Unlike filter-branch, which historically left such a tag pointing at the old, unrewritten commit, filter-repo’s default behavior is to simply drop the tag from the rewritten repository’s refs – so after a run that reports success, a project’s release tags can be gone outright, not pointing at the wrong commit, just absent, because the commit they referenced was swept up by the very same filter that was only meant to clean up unrelated files.
🔎 The Problem
$ git filter-repo --path src/ --path README.md # keep only these paths ... New history written in 4.21 seconds... Completely finished after 6.38 seconds. $ git tag v2.0.0 v2.1.0 # v1.5.0 is missing - it pointed at a commit that only modified # docs/CHANGELOG.md, a path the filter didn't keep, so filter-repo # had no rewritten commit to re-target the tag onto and silently # dropped it from the rewritten history's refs entirely
✅ Fix: Audit Tags Before You Filter
- Before running filter-repo with any path filter, list every existing tag and the commit each one points to, so you have a record of what should still exist afterward to check against.
- If a tag’s target commit falls outside the kept paths, decide deliberately whether that tag should be remapped to the nearest kept ancestor, preserved as a ref pointing at the original commit in a separate backup clone, or genuinely allowed to disappear – rather than discovering the gap only when someone later asks where a release tag went.
- Keep the original, unfiltered clone until every tag has been checked against the rewritten repository, since it’s the only place the original tag-to-commit mapping still exists once the filtered repo has been pushed.
🚨 Why This Is Dangerous
A release tag that’s simply gone, with no error and no warning in the filter-repo output, can go unnoticed for months until someone tries to check out that exact release and finds it doesn’t exist anymore – by then, the only copy of the original mapping may be an old clone someone happens to still have lying around.
filter-repo rewrites what it can reach from the paths you kept – a tag pointing anywhere else isn’t moved, it’s just left with nothing to point at.




