Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git: Show last commit date and message for each file in directory like Github [duplicate]

Tags:

git

github

In Github, when browsing a directory using the web interface, one can see when each file and subdirectory was last committed in addition to its commit message.

How would you do the same thing using the git command line interface?

like image 208
gvl Avatar asked Jun 28 '13 07:06

gvl


1 Answers

Ok, I modified this answer a bit to produce a nicer format. Here's the result in ZSH

enter image description here

And here's the script

#!/bin/sh

FILES="$(git ls-tree --name-only HEAD .)"
MAXLEN=0
IFS="$(printf "\n\b")"
for f in $FILES; do
    if [ ${#f} -gt $MAXLEN ]; then
        MAXLEN=${#f}
    fi
done
for f in $FILES; do
    str="$(git log -1 --pretty=format:"%C(green)%cr%Creset %x09 %C(cyan)%h%Creset %s %C(yellow)(%cn)%Creset" $f)"
    printf "%-${MAXLEN}s -- %s\n" "$f" "$str"
done

Here's the gist source

like image 59
Gabriele Petronella Avatar answered Oct 21 '22 02:10

Gabriele Petronella