Skip to content

Instantly share code, notes, and snippets.

@emad-elsaid
Created June 3, 2019 11:45
Show Gist options
  • Save emad-elsaid/ab7cd2cf5dd41e0fa0004118ea48a980 to your computer and use it in GitHub Desktop.
Save emad-elsaid/ab7cd2cf5dd41e0fa0004118ea48a980 to your computer and use it in GitHub Desktop.
accepts a file or stream of file paths and it'll return every file with the last commit message and time under every path, and example down below

this script will read every line (file path) passed to it, then shows the last commit message and time (human readable period), you can use it to see who added png images and when to your project for example:

git ls-files | grep png | git-last-commit

you can get some results similar to the following:

images/screenshot.png
digitalcraftsman: Updated screenshots -- 3 years, 11 months ago
images/tn.png
digitalcraftsman: Updated screenshots -- 3 years, 11 months ago
static/images/avatar.png
digitalcraftsman: Added assets -- 4 years ago
static/images/[email protected]
digitalcraftsman: Added assets -- 4 years ago
#!/usr/bin/env bash
while read line; do
echo $line
git log -n 1 --pretty=format:'%Cblue%an: %Cgreen%s %Cblue-- %ar %Creset' $line
done < "${1:-/dev/stdin}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment