Git:显示Github等目录中每个文件的最后提交日期和消息 [英] Git: Show last commit date and message for each file in directory like Github

查看:335
本文介绍了Git:显示Github等目录中每个文件的最后提交日期和消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Github中,当使用Web界面浏览目录时,除了提交消息之外,还可以查看每个文件和子目录何时上次提交。



你使用 git 命令行界面做同样的事情吗?

好的,我稍微修改了


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

这篇关于Git:显示Github等目录中每个文件的最后提交日期和消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆