Skip to content

Instantly share code, notes, and snippets.

@sordina
Created August 2, 2011 11:51
Show Gist options
  • Save sordina/1120049 to your computer and use it in GitHub Desktop.
Save sordina/1120049 to your computer and use it in GitHub Desktop.
View all revisions of a git versioned file at once, marked by revision and date
#!/bin/bash
file="$1"
# Date flag
if [[ "$file" == "-v" ]]
then
file="$2"
verbose=1
fi
export file
export verbose
if [ "X" == "X$file" ]
then
echo "Usage: git-history <path>"
exit 1
fi
function difference_engine() {
printf -- "---------- $1:$file\n\n"
if [[ "$verbose" ]]
then
git shortlog "$1" | tail -n 2
printf -- "----------\n\n"
fi
git --no-pager show "$1:$file"
printf "\n\n"
}
export -f difference_engine
cd "`dirname \"$file\"`" && git rev-list --reverse --children --all -- "$file" | sed -e 's/ .*//' | xargs -n 1 -I % bash -c 'difference_engine %'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment