git diff -Garegex
在 msysgit 1.7.4 上运行良好,但仅在 bash 会话中(在 DOS 会话中,它不返回任何内容)
It will display the diff
if the regex matches a line added or removed from the staged version.
added or removed: not changed.
Meaning in your case, it won't work
The OP eckes https://stackoverflow.com/users/520162/eckes报告它可以工作(仅适用于 msysgit1.7.4+),并补充说diff手册页 http://git-scm.com/docs/git-diff for -G
选项包括:
“寻找差异added or removed行与给定的正则表达式匹配”,
这与 diff 输出有关其中更改的行被打印为添加一行和删除一行.
示例:我添加一个新行“aaa”(没有git add
: 只是简单的编辑)
$ git diff -Gaaa
diff --git a/conf/fragments/xxx_repos.conf b/conf/fragments/xxx_repos.coindex 263fa85..3475f9b 100644
--- a/conf/fragments/xxx_repos.conf
+++ b/conf/fragments/xxx_repos.conf
@@ -10,3 +10,4 @@ repo xxx-sdsfwk
RW+ = vonc user1 user2
RW = @xxx_users
xxx-sdsfwk "Owner" = "for..."
+aaa
请注意,在 Git 2.33(2021 年第 3 季度)中,使用--pickaxe-regex
(通常保留用于-S
)不可能与-G
(无论如何它已经使用了正则表达式)。
See commit 5d93460 https://github.com/git/git/commit/5d93460024541909337d6b08a8bec10b71caaf73, commit 22233d4 https://github.com/git/git/commit/22233d43eb5479d1076e034eb5cdba973fa2b02a, commit f97fe35 https://github.com/git/git/commit/f97fe358576c81d995843644ab58de1ebeb7fee9, commit fa59e7b https://github.com/git/git/commit/fa59e7beb2a61d9cd1312b212075edf12935fdc6, commit 9e20442 https://github.com/git/git/commit/9e204422985a518ac700889d1ca4d521b3a7bfb2, commit a8d5eb6 https://github.com/git/git/commit/a8d5eb6dc0d61625667b0d8155c425d3629baa12, commit 5b0672a https://github.com/git/git/commit/5b0672a26e51387bc18adad89eaa3ebb131b2e33, commit 5d35a95 https://github.com/git/git/commit/5d35a9531cc9af717383bc11c2dfa4edc020ac56, commit 52e011c https://github.com/git/git/commit/52e011cd2b13e00fe40b1d59986948330b61e030, commit 2e197a7 https://github.com/git/git/commit/2e197a759221921d42c5e94ae3f4897cd456ebb4, commit 03c1f14 https://github.com/git/git/commit/03c1f14acf5169d8e6c06a60c28ee5a6cfb9fd54, commit d90d441 https://github.com/git/git/commit/d90d441c336cc120b47e025d14c3879864ce60c5, commit 102fdd2 https://github.com/git/git/commit/102fdd2e07f72919060224b3eb3560524d6cf1f9, commit a47fcbe https://github.com/git/git/commit/a47fcbe6e412df295f1f5ffb8eca6dbe86d2b7bb, commit d26ec88 https://github.com/git/git/commit/d26ec8800969ea1b692e0c87100dc4235cfa12e2, commit 188e9e2 https://github.com/git/git/commit/188e9e28c5287f3f160b5f14e3e551b1c55c7301, commit 7cd5d5b https://github.com/git/git/commit/7cd5d5b299497fb874897595c642144d7d894ee4, commit 064952f https://github.com/git/git/commit/064952fc34b9765282fec057b3af260eae7c75c6, commit 69ae930 https://github.com/git/git/commit/69ae93089cd892d70429f7f06371860d65cb1f1b, commit c960939 https://github.com/git/git/commit/c9609398580518dffaadaace17188c901a4a4522, commit 6d0a401 https://github.com/git/git/commit/6d0a40166e87a78ca17fddeee25228ded92a169e, commit ecbff14 https://github.com/git/git/commit/ecbff141a1c6e4a32a43f90db70cde2b2199b241 (12 Apr 2021) by Ævar Arnfjörð Bjarmason (avar) https://github.com/avar.
(Merged by Junio C Hamano -- gitster -- https://github.com/gitster in commit 4da281e https://github.com/git/git/commit/4da281e84d87b099ba8d0a255534dc1251be968e, 13 Jul 2021)
pickaxe https://github.com/git/git/commit/188e9e28c5287f3f160b5f14e3e551b1c55c7301: 死时-G
and --pickaxe-regex
被合并
Signed-off-by: Ævar Arnfjörð Bjarmason
当。。。的时候-G
and --pickaxe-regex
选项组合在一起我们只是忽略--pickaxe-regex
option.
让我们按照我们的文档的建议去死吧,因为-G
始终是正则表达式。
When --pickaxe-regex
被添加到d01d8c6 https://github.com/git/git/commit/d01d8c6782850c18d62676dae3c72ad73be1e52e(“支持镐匹配正则表达式”,2006-03-29,Git v1.3.0-rc4 --merge https://github.com/git/git/commit/46e48c36043447b9739cdd7cae768dc53b5bc89d) 只有-S
选项存在。
那么当-G
被添加到f506b8e https://github.com/git/git/commit/f506b8e8b5fb231e63b69668b6b7516f12b32228(“git log/diff:在补丁文本中添加 grep 的 -G”,2010-08-23,Git v1.7.4-rc0 --merge https://github.com/git/git/commit/b3c16ee454effda5ec8033ab665249710f622699)既没有文档--pickaxe-regex
进行了相应更新,也没有添加类似此断言的内容。
Since 5bc3f0b https://github.com/git/git/commit/5bc3f0b56779d189aaf7cab7e5d307aa4e7c0887(“diffcore-pickaxe 文档:文档 -S 和 -G 正确”,2013-05-31,Git v1.8.4-rc0 --merge https://github.com/git/git/commit/71e120202fe073bd2e4e9db59ca01ab7c5e72f7e)我们声称--pickaxe-regex
应该只与使用-S
,但默默地容忍将其与-G
,我们还是去死吧。