How to move commits after git filter-branch

I’ve read that you’re supposed to be able to use git rebase to move commits from an old repo to a one after using git filter-branch. But I couldn’t get that to work.

The backstory: Our repo was bloated because we started by forking a different project, and then deleted unneeded parts. This was an easy way to get started, but we ended up with all the history of the old project. So I ran git filter-branch and some other tools to clean up the history and remove empty merge commits. While I was preparing that, the rest of the team kept working on the old repo.

So I had to move those commits the rest of the team made onto the new, filtered repo. I used git format-patch and git am. Like this (assuming cwd is the new repo):

( cd ../old-repo; git format-patch --stdout -k commit id on old-repo of last shared commit ) | git am -k

Leave a Reply