Find commits that refer to specific LFS object

Viewed 160

I am about to push my local repo to a new GitHub repo and I receive the following error:

remote: error: GH008: Your push referenced
        at least 1 unknown Git LFS object:
remote:     B41C79ADE3155B758388A338200A7B2A79E9FDBF48D5C4AFEDCE03886F4B873A
remote: Try to push them with 'git lfs push --all'.

I can confirm that the object isn't there. Is there a command to list which commits refer to this LFS object?

P.S. git fsck --full doesn't fail

1 Answers

All your local commits that aren't already in origin's history:

git rev-list  \
        $(git for-each-ref --format='%(refname)' refs/heads refs/tags) \
        --not $(git for-each-ref --format='%(refname)' refs/remotes/origin)

search all of those for references to that hash in lfs stubs:

alias doit='git for-each-ref --format="%(refname)"'
search=$( git rev-list  \
                $(doit refs/heads refs/tags) --not $(doit refs/remotes/origin)
)
git grep -i B41C79ADE3 $search -- ':(attr:filter=lfs)*'
Related