gitgit-filter-branchgit-gc

Forgot to rm refs/original after git filter-branch


I forgot to rm refs/original after git filter-branch and did git gc, which cleared refs. I also committed into the new repo, and would like to keep these commits.

The extracted branch has a size of a few kilobytes, but .git still weights 80 MB, just like before the filtering.

Now refs is empty, and I cannot easily delete refs/original anymore. How can I still remove the originals? I would like to avoid having to filter-branch again if possible.


Solution

  • Your refs got packed (git gc runs git pack-refs). That makes no changes to the refs themselves, except that rather than having each one in a separate file, they're all in the "packed" fie.

    You simply need to delete the refs/origina/ refs. In theory using git update-ref -d on each one should work, but if there are many, it's probably easier to open .git/packed-refs in your editor and manually delete all the refs/original/ lines.

    You might also need to clear out reflogs.

    See this StackOverflow answer for more.