6

There's a huge binary commit I'd like to prune from my repo.

> git log --all -- '*.tiff'
commit 05f03aba18164c736182e612181f99ce04e38845
...

It's not part of a branch...

> git branch --all --contains 05f03aba
> (nothing)

..., it's not pointed to by a tag and it can't be referenced by the reflog. (I've cleared it with git reflog expire --expire=now --all)

Yet the commit is somehow referenced and therefore not pruned:

> git fsck --unreachable
> (nothing)

How can I find out what causes the commit to be referenced?

Kay Sarraute
  • 1,232
  • 8
  • 16
  • 1
    Your second command must be `git branch --all --contains xxx` (otherwise you'll miss remote-tracking branches). Also, you need to check the tags. – sleske Dec 16 '12 at 12:22

1 Answers1

3

If your commit is reached by git log, you can just run git log --source to show from where your commit was reached.

It might be referenced by a backup of git filter-branch – see this question for more detail: Remove refs/original/heads/master from git repo after filter-branch --tree-filter?

Community
  • 1
  • 1
Chronial
  • 66,706
  • 14
  • 93
  • 99
  • Solved: `git log --source` revealed that the commit was in `refs/original/refs/heads/master`. After deleting the corresponding line from `repo/.git/packed-refs`, GC could remove the blob. Where did this `refs/original/refs/...` come from? How could I have deleted it with Git's command line tools? – Kay Sarraute Dec 16 '12 at 12:51
  • 3
    `refs/original/refs/` is created by `git filter-branch`, as a backup. See e.g. http://stackoverflow.com/questions/7654822/remove-refs-original-heads-master-from-git-repo-after-filter-branch-tree-filte – sleske Dec 16 '12 at 13:00
  • Extended the answer with these infos. – Chronial Dec 16 '12 at 13:12
  • 1
    You can use `git update-ref -d` to delete the ref: http://stackoverflow.com/questions/7654822/remove-refs-original-heads-master-from-git-repo-after-filter-branch-tree-filte – John Szakmeister Dec 17 '12 at 13:00