git统计某段时间内代码的修改量/总代码量

1.前往git本地项目路径下

2.右键打开(Git Bash)工具

3.输入命令:

1)某段时间代码修改量

git log --since=2021-01-01 --until=2021-05-18 --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 }'

修改时间段为自己所需时间段

2)总代码量

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 }'

 

  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
您可以通过在`git log`命令中使用`--since`和`--until`参数来获取某个人在一段时间内的代码。以下是一些命令: 1. 获取某个作者在指定日期范围内的代码 ``` git log --author=<author_name> --since=<start_date> --until=<end_date> --pretty=tformat: --numstat | awk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines: %s total lines: %s",add,subs,loc }' - ``` 其中,`<author_name>`是需要统计代码的作者名字,`<start_date>`和`<end_date>`分别是起始日期和结束日期。例如,如果您想获取某个作者在2021年5月1日到2021年5月31日之间的代码,您可以这样输入命令: ``` git log --author=<author_name> --since=2021-05-01 --until=2021-05-31 --pretty=tformat: --numstat | awk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines: %s total lines: %s",add,subs,loc }' - ``` 2. 获取某个作者在最近n天内的代码 ``` git log --author=<author_name> --since=<n_days_ago> --pretty=tformat: --numstat | awk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines: %s total lines: %s",add,subs,loc }' - ``` 其中,`<author_name>`是需要统计代码的作者名字,`<n_days_ago>`是最近n天的日期(例如,7天前是`7.days.ago`)。例如,如果您想获取某个作者在最近7天内的代码,您可以这样输入命令: ``` git log --author=<author_name> --since=7.days.ago --pretty=tformat: --numstat | awk '{ add += $1 ; subs += $2 ; loc += $1 - $2 } END { printf "added lines: %s removed lines: %s total lines: %s",add,subs,loc }' - ``` 请注意,在使用这些命令之前,请确保您已经克隆了整个Git仓库,并且已经切换到正确的分支。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值