Skip to content

Instantly share code, notes, and snippets.

@LukasWoodtli
Created August 18, 2025 08:12
Show Gist options
  • Save LukasWoodtli/4e97dab762888377a3efa33e5c14bf0a to your computer and use it in GitHub Desktop.
Save LukasWoodtli/4e97dab762888377a3efa33e5c14bf0a to your computer and use it in GitHub Desktop.
Check git history for changed files
#!/usr/bin/env sh
set -u
set -e
to_rev=$1
from_rev=$2
revs=$(git rev-list "$to_rev".."$from_rev")
for rev in $revs
do
echo Checking commit:
git log -n1 --oneline "$rev"
if git diff-tree -r --diff-filter=M "${rev}^!" | awk '{ print $5 }' | grep -q M
then
echo File changed!
git diff --raw "${rev}^!"
exit 1
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment