Showing the latest changes of each subdirectory in git

后端 未结 3 543
不知归路
不知归路 2021-01-05 19:06

In github if you open a repository you will see a page showing the latest commit and time of each subdirectory and file.

Can I do this by command line in git?

3条回答
  •  渐次进展
    2021-01-05 19:20

    Thanks answers from Klas Mellbourn and Nevik Rehnel, finally I combined these two versions into mine:

    #!/bin/bash
    
    FILES=`ls -A`
    MAXLEN=0
    for f in $FILES; do
        if [ ${#f} -gt $MAXLEN ]; then
            MAXLEN=${#f}
        fi
    done
    for f in $FILES; do
        str=$(git log -1 --format="%cr      [%cn]   %s" $f)
        printf "%-${MAXLEN}s -- %s\n" "$f" "$str"
    done
    

    Outputs:

    $ bash view.bash
    android_webview   -- 4 months ago       [boxxx@chromium.org]    Disable testCalledForIframeUnsupportedSchemeNavigations
    ash               -- 4 months ago       [osxxxx@chromium.org]   Rename _hot_ -> _hover_
    cc                -- 4 months ago       [enxx@chromium.org]     cc: Let impl-side painting use smaller tiles
    chrome            -- 5 weeks ago        [Deqing]     Set the nacl pipe to non-blocking
    tools             -- 10 weeks ago       [Haxx Hx]    Add submodule tools/gyp
    

提交回复
热议问题