2

I found a big object file from .git/objects/ , I am wondering that what the file is(when added, from which file in working directory).

I tried cat-file but it shows only contents, not file names.

Is there a git command find file name(path) from object hash, It is like:

% git find-path? <object-hash>
-> List of filename(path) of this object
hoge1e3
  • 802
  • 5
  • 15

1 Answers1

3

Man, blobs can be linked to a tree with any given name... and then trees (linked trees) can be linked to revisions with different names... so a blob can have PLENTY of different names. The best thing I can think of is traversing the history to see what you can find:

git log --all --pretty="%h" | while read rev; do lines=$( git ls-tree -r $rev | grep the-id-of-the-blob | wc -l ); if [ $lines -ne 0 ]; then echo Blob is in revision $rev; git ls-tree -r $rev | grep the-id-of-the-blob; fi; done
eftshift0
  • 26,375
  • 3
  • 36
  • 60