Git: Show the latest commit date and message for each file in a directory such as Github

In Github, when viewing a directory using the web interface, you can see when the last file and subdirectory were last committed in addition to the message about its commit.

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

+8
git github
source share
2 answers

Ok, I slightly modified this answer to create a more convenient format. Here is the result in ZSH

enter image description here

And here is 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 is the source of gist

+19
source share

I am using the following line:

git log --decorate=full --pretty=full --graph -b --stat

You should put it in your .gitconfig as an alias (Perso, I use git l for this.)

+2
source share

All Articles