Last active
April 14, 2021 01:21
-
-
Save sorohan/7a32b32ad52134fce0055a65aa3942eb to your computer and use it in GitHub Desktop.
Find a lost file from an orphaned git commit.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
file=$1 | |
for f in $(git fsck --lost-found | grep 'dangling commit' | awk '{print $3}'); do | |
git log --stat $f | grep $file &> /dev/null; | |
if [ $? -eq 0 ]; then | |
git log -1 $f; | |
fi; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment