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?
Ok, I modified this answer a bit to produce a nicer format. Here's the result in ZSH
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With