Tim Woodall wrote: > On Tue, 9 Dec 2025, Bryan Gardiner wrote: > >> Hi Tim, >> >> On Tue, 9 Dec 2025 19:48:06 +0000 (GMT) >> Tim Woodall <[email protected]> wrote: >> >>> I want to rewrite git history from the very first commit (which is an >>> empty commit) but nothing I can find seems to let me do this other >>> than with manual intervention. >>> >>> This is a one off and doesn't need to be efficient so long as I can >>> leave it to get on with it without intervention. >> >> The built-in way to do this is to use `git filter-branch`. There are >> a number of examples on the git-filter-branch man page, and it looks >> like a combination of the --tree-filter and --env-filter arguments >> would make the modifications you want. >> > Yes! This works. Thanks. (at least the tree-filter bit)
Though it is worth noting that `git filter-branch` is
discouraged by upstream now, in favor of `git filter-repo`¹.
The man page starts with the following warning:
git filter-branch has a plethora of pitfalls that can produce
non-obvious manglings of the intended history rewrite (and can
leave you with little time to investigate such problems since it
has such abysmal performance). These safety and performance
issues cannot be backward compatibly fixed and as such, its use
is not recommended. Please use an alternative history filtering
tool such as git filter-repo[1]. If you still need to use git
filter-branch, please carefully read the section called “SAFETY”
(and the section called “PERFORMANCE”) to learn about the land
mines of filter-branch, and then vigilantly avoid as many of the
hazards listed there as reasonably possible.
For the relatively simple case of rewriting the author and
committer, I imagine filter-branch works well enough. But
for many other uses, folks are likely to be tripped up by
its warts and wish they had used filter-repo instead. :)
`git fast-export | ... | git fast-import` can also be used
(though perhaps not as easily as filter-branch or
filter-repo for the author and committer rename example.)
¹ https://github.com/newren/git-filter-repo/
--
Todd
signature.asc
Description: PGP signature

