diff --git a/git_find_exact_file_based_on_hashsum.sh b/git_find_exact_file_based_on_hashsum.sh new file mode 100755 index 0000000..004bdeb --- /dev/null +++ b/git_find_exact_file_based_on_hashsum.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# from: https://www.endpoint.com/blog/2014/11/10/finding-specific-git-commit-at-point-in + +FILE=$1 +HASH=`git hash-object $FILE` +echo "Looking for hash $HASH, of file $FILE" +git rev-list --all \ + | while read commit + do if git ls-tree -r $commit \ + | grep -F -q $HASH + then echo "found in git commit $commit" + break + fi + done