Skip to content

Instantly share code, notes, and snippets.

@samredai
Created March 12, 2020 15:36
Show Gist options
  • Save samredai/bf31394aa5cd825a428d2b301971aead to your computer and use it in GitHub Desktop.
Save samredai/bf31394aa5cd825a428d2b301971aead to your computer and use it in GitHub Desktop.
Git: Get all commit diffs for a single file
# Retrieve all commit hashes that include the particular file
git log -p path/to/target/file/filename.py | grep -n "^commit" | grep -Eo "[^ ]+$" > ~/commit_hashes.txt
# Loop through and perform a git diff on each hash
while read line; do git diff $line; done < ~/commit_hashes.txt > commit_diffs.txt
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment