Git常用命令备份

备份一下日常用命令

引用

git代码统计-segmentfault

所有在Windows下用cmder都可以执行

  1. 查看提交次数:
1
2
3
git shortlog --numbered --summary
55 Gsealy
3 JEDI
  1. 删除本地提交
1
git reset --soft HEAD~1
  1. 查看git上的个人代码量(修改username
1
git log --author="username" --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 }' -
  1. 统计每个人增删行数
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
  1. 添加或修改的代码行数
1
git log --stat|perl -ne 'END { print $c } $c += $1 if /(\d+) insertions/'
Buy Me A Coffee.