git - 如何让 Git diff 忽略版本号更改?

标签 git diff git-diff

有没有办法从 Git diff like this one 中移除版本号更改噪音? ?具体来说,如果一行只包含从一个数字到另一个数字的更改,我可以设置 Git diff 来忽略它吗?

最佳答案

我认为这可以使用 git-diff --word-diff-regex=[^0-9] ( see [^0-9] in action ) 来实现。对于更复杂的模式,您需要更复杂的正则表达式,但是,except recursion , 正则表达式一切皆有可能

来自 Git - git-diff --word-diff-regex documentation

--word-diff-regex=

Use < regex > to decide what a word is, instead of considering runs of non-whitespace to be a word. Also implies --word-diff unless it was already enabled.

Every non-overlapping match of the < regex > is considered a word. Anything between these matches is considered whitespace and ignored(!) for the purposes of finding differences. You may want to append |[^[:space:]] to your regular expression to make sure that it matches all non-whitespace characters. A match that contains a newline is silently truncated(!) at the newline.

For example, --word-diff-regex=. will treat each character as a word and, correspondingly, show differences character by character.

The regex can also be set via a diff driver or configuration option, see gitattributes[5] or git-config[1]. Giving it explicitly overrides any diff driver or configuration setting. Diff drivers override configuration settings.

另见

关于git - 如何让 Git diff 忽略版本号更改?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49135986/

相关文章:

linux - 使用 mkdir 数据 : permission denied 设置后全新安装 gogs panic

python - 使用 SequenceMatcher (Python) 生成内容差异

diff - 是否可以在并排差异输出中显示行号?

git - 如何让 git log 显示相对于当前目录的文件路径?

emacs - 如何使用 Magit 比较单个文件?

git - Microsoft Git Provider 和 Visual Studio 2012 启动配置比较工具失败

python - 我可以从 python git pre-receive hook 前缀错误 : instead of remote: 返回消息吗

Git 差异到 Perforce?

python - 如何通过 ID 保留第一个条目? Pandas python

linux - 如何给补丁文件上色