查看代码行数
1.进入代码所在目录,使用 git bash 打开命令行
2.git log --since=2023-07-01 --until==2023-11-10 --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 }’
(上面的命令就是查询2022年7月1日到2022年11月10日这段时间的代码统计)
环境 win10, 具体使用
生成公钥私钥 : ssh-keygen -t rsa -C “你的邮箱” -b 4096
一路回车
-
首先安装git,这个不在本篇范围内,网络上一大把教程,先高抬贵手百度一下。
-
找一个目录在空白处右键打开git base
-
在git base命令输入 git init :初始化git
-
创建远程仓库,这部分略过,高抬贵手百度…哈哈哈
-
关联远程仓库,这里举例我自己的远程仓库, 输入命令 git remote add origin https://github.com/yanzijie/go_learning.git
-
验证是否成功关联 git remote -v
-
拉取远程代码 git fetch origin master
-
增加本地代码 git add -u
-
提交刚才添加的代码到本地工作区 git commit -m “这是备注”
-
合并远程分支代码到本地分支 git merge origin/master
-
把合并的分支再推送到远程分支 git push origin master:master
好了,到这里就可以玩耍了
查看个人提交和移除的代码行数
1.查看自己的用户名:
git config user.name
2.根据自己的用户名来查看提交和移除的代码行数, 总数
git log --author="你的用户名" --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 }' -
3.查看规定时间内的行数:
git log --since='2023-01-01' --before='2023-03-01' --author="你的用户名" --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 }' -
4.查看总提交行数、移除行数、项目总行数
git log --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 }'
5.查询所有用户的提交总次数
git log --pretty='%aN' | sort | uniq -c | sort -k1 -n -r