EDIT: Update Based on New Test Results Using Git Version 2.7.4
It looks like the solution I posted only goes through reflog. Therefore, if you delete the reflog entry, that entry will not be viewed - even if the object still exists.
So you will need to do something like:
{ git rev-list --objects --all --grep="text" git rev-list --objects -g --no-walk --all --grep="text" git rev-list --objects --no-walk --grep="text" \ $(git fsck --unreachable | grep '^unreachable commit' | cut -d' ' -f3) } | sort | uniq
Derived from: Git - how to display ALL objects in the database
Old solution: only works if the object is in reflog
To find the string "text" in all local objects:
git log --reflog -Stext
To find the template template in all local objects:
git log --reflog --grep=pattern
This will search all objects, so it will work even if the commit / branch command is removed. When an object is deleted from the local repository (for example, via gc), it will no longer be included in the search.
vman source share