美文网首页
git查看某人某段时间的代码提交

git查看某人某段时间的代码提交

作者: eyow | 来源:发表于2017-06-09 11:06 被阅读2113次
    // 查询所有提交者
    git log --since ==2017-09-01 --until=2017-09-28 
    --format='%aN' | sort -u | while read name; do echo -en "$name\t"; git log --author="$name" --pretty=tformat: --numstat | awk '{ add += $1; subs += $2; loc += $1 + $2 } END { printf "added lines: %s, removed lines: %s, total lines: %s\n", add, subs, loc }' -; done
    
    // 查询单人
    git log --since=2017-05-21 --until=2017-06-20 --author="author-name" --pretty=tformat: --numstat | gawk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines : %s total lines: %s\n",add,subs,loc }' -
    

    默认不用任何参数的话,git log 会按提交时间列出所有的更新,最近的更新排在最上面。
    --pretty 选项,可以指定使用完全不同于默认格式的方式展示提交历史。
    format,可以定制要显示的记录格式,这样的输出便于后期编程提取分析,像这样:

     $ git log --pretty=format:"%h - %an, %ar : %s"
    ca82a6d - Scott Chacon, 11 months ago : changed the version number
    085bb3b - Scott Chacon, 11 months ago : removed unnecessary test code
    a11bef0 - Scott Chacon, 11 months ago : first commit
    

    下表列出了常用的格式占位符写法及其代表的意义。

    常用的格式占位符

    git log 命令支持的常用选项及其释义。

    选项及释义

    git log常用搜索条件

    常用搜索条件

    </br>
    参考:https://git-scm.com/book/zh/v1/Git-基础-查看提交历史

    相关文章

      网友评论

          本文标题:git查看某人某段时间的代码提交

          本文链接:https://www.haomeiwen.com/subject/ftixqxtx.html