Make git `replace` commits permanent (or such)

2.6k views Asked by At

I'm busy converting all my existing SVN repositories to Git, and at the same time also take the opportunity to use Git's ability to easily rewrite some history. For this I'm also using git filter-repo, to get rid of unwanted files and do some standard renaming via scripts. (note: they're all solo repositories only I work in, so no history altering disclaimers are needed, I know the caveats :) )

filter-repo works beautifully (with the Python scripting capabilities plus it's much faster than filter-branch), but it creates replace commits. Once the repo restructuring is done I'd like to get rid of all these replace commits again to really bake in the changed history. And preferably via a script since I've got lots of repos with lots of commits. I however turned up empty handed when googling for how to do this...

The reason for this: my Git command line client isn't bothered by this, but my GUI (SmartGit for Windows) keeps nagging that it doesn't support replace commits (it detected refs/replace-refs it says). It displays the repo contents OK anyway, and I can continue from there filling in missing commit messages, do some more cleanup etc., but I didn't look further yet so who knows what it will eventually break?

I already found a workaround by pushing each repo to an empty repo added to a local Gitea server, then just deleting the local repo and cloning it back to local. While I can live with that for the rest of my conversion journey, I keep wondering if I can/could have done it more efficient?

1

There are 1 answers

5
VonC On BEST ANSWER

If the refs/replace-refs are problematic, you could run your filter-repo command with the
--replace-refs option.

Try it with:

--replace-refs update-no-add
# or
--replace-refs delete-no-add

See if there are still refs/replace-refs objects after the filter-repo execution then.

A. Chiesa confirms in the comments:

Simply running git filter-repo --replace-refs delete-no-add worked in my case.
I had no usages of replace refs, except for the ones created by filter-repo, and the command gets rid of all of those.