I am using this script to compute the n largest blops in my repository:
An example of the output:
54016,13273,0ef462bf57e8c036b00b52d6cc0fd91b2fc2a827 Data/Db.MDF
30976,8734,3e162c8313995980c8d6fc434c06789373364a47 Tools/connector.dll
The two SHAs above are SHAs for the blops. Now I would like to locate the commit/branch that contains those blops. I first tried:
$ git branch -a --contains 3e162c8313995980c8d6fc434c06789373364a47
error: object 3e162c8313995980c8d6fc434c06789373364a47 is a blob, not a commit
As the message says above the SHA is for a blob not a commit. This leads me to: Which commit has this blob?
I have created the two scripts from the above post and added those to the root of my repository. But when I run them nothing gets outputted:
MINGW64 /c/tmp/MyRepo (master)
$ ./blop-to-commit.sh 3e162c8313995980c8d6fc434c06789373364a47
MINGW64 /c/tmp/MyRepo (master)
Also tried to run it on a local bare clone of the repository:
MINGW64 /c/tmp/MyRepo.bare (BARE:master)
$ ./blop-to-commit.sh 3e162c8313995980c8d6fc434c06789373364a47
MINGW64 /c/tmp/MyRepo.bare (BARE:master)
Any ideas why I don't get the commit/branch that contained that blop at some point in history?
EDIT/SOLUTION:
Seems I just had to add the --all option to the git log command:
shift
git log --all "$@" --pretty=format:'%T %h %s' \
| while read tree commit subject ; do
if git ls-tree -r $tree | grep -q "$obj_name" ; then
echo $commit "$subject"
fi
done
As suggested below:
$ git fsck
Checking object directories: 100% (256/256), done.
Checking objects: 100% (100278/100278), done.
Checking connectivity: 100342, done.
dangling commit 3f8cd0a581ec694e7371f7e4183e1cad8fa87647
dangling commit d5c0f41337ae1ef8e5cfbfd4f70077c36d231cf1
dangling commit b01831f4e6679ef2696a83e6dbaa04eaf6748f85
dangling commit 82b32531c23202d123f693bba64b040b3247636b
dangling commit 4fa8ce87c268a7ddb7c4e72d6810f70e197d5812
dangling commit 3ce38a0b8e5dbb7424a88359bbe0d9130ced34dc
I then did:
git reflog expire --expire-unreachable=now --all
git gc --prune=now
But I still don't see corresponding commits for the blobs originally listed.