我没有看到任何明显的方法,但是git已经一次又一次证明比我想象的更灵活,所以......
我想找到引入大代码更改的提交,因此我想根据插入或删除的行数(一起或单独)来限制它们。有没有办法做到这一点?
答案 0 :(得分:3)
git log --stat
commit e2b97c53727bd66c143713d13399ff4242e4ff06
Author: John Hobbs
Date: Thu Nov 4 17:01:14 2010 -0500
Switched to jQuery Mobile. It's awesome.
application/classes/controller/item.php | 77 +++++++++++++---------------
application/classes/controller/project.php | 4 +-
application/classes/controller/site.php | 2 +
application/classes/controller/user.php | 5 +-
application/classes/form.php | 2 +-
application/views/item/add.php | 27 +++-------
application/views/item/index.php | 19 ++-----
application/views/item/view.php | 11 +++--
application/views/message/basic.php | 13 +++++
application/views/mobile.php | 64 ++++++++++++++++++-----
application/views/project/add.php | 5 +--
application/views/project/index.php | 28 ++++------
application/views/project/view.php | 19 ++-----
application/views/user/index.php | 25 +--------
application/views/user/login.php | 14 +++--
application/views/user/register.php | 20 ++++---
16 files changed, 165 insertions(+), 170 deletions(-)
(来自here的示例输出)
然后直观地查找长+/-符号或使用--numstat
并将其传递给另一个命令来过滤它。
man git log
如果您需要过滤它而不是按照Antoine的建议--shortstat
进行过滤:
$ git log --pretty=oneline --shortstat
这将为您提供如下输出:
$ git log --pretty=oneline --shortstat
19791900f886e7a5f92b7cf3536053c863bec067 fix tab title, system menu, and a focus
2 files changed, 108 insertions(+), 65 deletions(-)
b52941150046cdb455c38e3f9bc133d6ba8f721f give tab a wndproc, change time to be
1 files changed, 65 insertions(+), 20 deletions(-)
ae5c18524b4a02b264fe26319ce2c9cf7dbff6b2 Fix window style of parent window
1 files changed, 1 insertions(+), 1 deletions(-)
8f94ad9bbbb2fec42feccda43374b13eda55c018 Add .gitignore to ignore some MSVC file
1 files changed, 10 insertions(+), 0 deletions(-)
管道到awk,搜索'文件已更改',并在插入次数大于50时打印匹配行和上一行:
$ git log --pretty=oneline --shortstat | awk '/files changed, / && $4 > 50 {print x; print};{x=$0}'
19791900f886e7a5f92b7cf3536053c863bec067 fix tab title, system menu, and a focus
2 files changed, 108 insertions(+), 65 deletions(-)
b52941150046cdb455c38e3f9bc133d6ba8f721f give tab a wndproc, change timer
1 files changed, 65 insertions(+), 20 deletions(-)
一些awk参数的来源:http://unstableme.blogspot.com/2008/05/print-currentnextprevious-line-using.html