Skip to content

Instantly share code, notes, and snippets.

@czue
Created November 14, 2017 07:06
Show Gist options
  • Save czue/4152fd5717fe72b89d68979167cdd017 to your computer and use it in GitHub Desktop.
Save czue/4152fd5717fe72b89d68979167cdd017 to your computer and use it in GitHub Desktop.
A little bash script for git blaming things matching git grep
#!/bin/bash
# usage: ./git_grep_blame.sh todo
# HT: https://stackoverflow.com/a/43664756/8207
if [ "$1" = "" ] ; then
echo "usage: $0 <term>" 1>&2
exit 1
fi
for file in $(git grep -i $1 | cut -d ':' -f 1 | uniq) ; do
echo $file ::
git blame $file | grep $1
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment