Rebranding a project without a single commit
I've been working on a project called Hybridly, but I couldn't find a name until long after the project was started. The project's codename was Monolikit.
I wanted to rebrand the project, but I didn't like the idea of having one big commit with a big search-and-replace. That would disrupt the history and cause trouble when using git blame
.
The first thing I tried was a git rebase -i
on the first commit - but that proved very tedious and I don't like manual work. So when looking for other solutions, I stumbled upon git-filter-repo
, a tool for rewriting Git history. Exactly what I needed.
After installing it with brew install git-filter-repo
, this simple one-liner solved all my problems:
git filter-repo \
--blob-callback 'blob.data = blob.data.replace(b"monolikit", b"hybridly").replace(b"Monolikit", b"Hybridly").replace(b"MONOLIKIT", b"HYBRIDLY")' \
--filename-callback 'return filename.replace(b"monolikit", b"hybridly").replace(b"Monolikit", b"Hybridly").replace(b"MONOLIKIT", b"HYBRIDLY")' \
--force
Basically, it goes over all the commits, and replace both Monolikit
and monolikit
with the new name.