git——git不常见指令记录
- 查看本次pull和上一次本地commit的文件变更情况
git diff --name-only `git reflog -n 2 | tail -n 1 | awk '{printf $1}'` `git reflog -n 1 | awk '{printf $1}'`
- 查看不同用户贡献的代码行数
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
- 统计代码行数
cloccloc --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}'
- 在裸库里统计代码行数
这会比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}'
试探性地留下名字