Skip to content

Commit

Permalink
added git_find_exact_file_based_on_hashsum.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
br-cpvc committed Jun 16, 2022
1 parent 66c2388 commit 465c991
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions git_find_exact_file_based_on_hashsum.sh
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 465c991

Please sign in to comment.