Git 实用命令

代码行数统计

git log --author=yourname --since=2023-01-01 --until=2023-12-31 --format='%aN' | sort -u | while read name; do echo -en "\n$name\t"; git log --author="$name" --pretty=tformat: --numstat | grep "\(.h\|.c\|.cpp\|.html\|.js\|.css\)$" | 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 branch | grep -v "^\*" | xargs git branch -D

压缩空间

git gc --aggressive

发表回复