1. 查看本次pull和上一次本地commit的文件变更情况
    git diff --name-only `git reflog -n 2 | tail -n 1 | awk '{printf $1}'` `git reflog -n 1 | awk '{printf $1}'` 
    
  2. 查看不同用户贡献的代码行数
    git log --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
    
  3. 统计代码行数
    cloc git——git不常见指令记录
    cloc --vcs=git . | grep SUM | awk '{file=$2;blank=$3;comment=$4;code=$5;lines=$3+$4+$5} END {printf "files: %s, blank lines: %s, comment lines: %s, code lines: %s, total lines: %s\n", file, blank, comment, code, lines}'
    
  4. 在裸库里统计代码行数
    这会比2更快,但是只有代码行,不能统计注释
    git diff `git rev-parse HEAD`  `git log --reverse | head -n 1 | awk '{print $2}'` --pretty=tformat: --numstat | awk '{total+=$2-$1} END {printf "%s", total}'
    git log `git log --reverse | head -n 1 | awk '{print $2}'` --pretty=tformat: --numstat | awk '{total+=$1-$2} END {printf "%s", total}'
    

相关文章:

  • 2022-02-02
  • 2021-08-07
  • 2022-12-23
  • 2021-04-15
  • 2021-12-10
猜你喜欢
  • 2021-08-08
  • 2021-08-01
  • 2021-08-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-11
  • 2021-09-26
相关资源
相似解决方案