据我所知here https://stackoverflow.com/questions/53450186/git-diff-show-only-changes-not-matching-a-pattern,我们可以告诉git diff
忽略以 a 开头的行*
using:
git diff -G '^[[:space:]]*[^[:space:]*]'
如何告诉 git 忽略以单词或更多单词开头的行(例如:* Generated at
),不只是一个角色?
该文件应被忽略,它只包含一些细微的更改:
- * Generated at 2018-11-21
+ * Generated at 2018-11-23
该文件不应被忽略,它不仅包含微不足道的更改:
- * Generated at 2018-11-21
+ * Generated at 2018-11-23
+ * This line is important! Although it starts with a *
Git 正在使用POSIX https://www.regular-expressions.info/posix.html正则表达式好像不支持环顾四周 https://www.regular-expressions.info/posix.html。这就是为什么@Myys 3 的方法 https://stackoverflow.com/a/53452408/2020827不起作用。一个不太优雅的解决方法可能是这样的:
git diff -G '^\s*([^\s*]|\*\s*[^\sG]|\*\sG[^e]|\*\sGe[^n]|\*\sGen[^e]|\*\sGene[^r]|\*\sGener[^a]|\*\sGenera[^t]|\*\sGenerat[^e]|\*\sGenerate[^d]).*'
这将过滤掉以“开头的所有更改* Generated
".
Test: https://regex101.com/r/kdv4V0/3 https://regex101.com/r/kdv4V0/3
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)