向 Git 添加提示以帮助解决差异
Adding tips to Git to assist with diffs
Git diff 经常认为小改动是非常大的改动而没有正确识别小改动的代码。
有没有一种简单的方法可以帮助 git,比如在源代码中添加一些标记,或者其他方式?
git diff
提供了多种忽略微小变化的方法:
- -w 忽略 Ignore whitespace when comparing lines
- -b 忽略 space-更改
- custom hunk headers 检测差异时显示函数头。
这是您可以添加的最接近 git diff
的提示,不是在文件本身中,而是在 .gitattributes
文件中。
参见例如“Is there a way to ask git diff
to show the method name instead of the class name?”。
但是,这是针对 local diff.
对于 GitHub,当文件为 "too large".
时,没有强制它显示差异的本机解决方案
类似的场景(仍在 GitHub)是 reported here,当看到
Sorry, we could not display the entire diff because too many files changed
I'm doing workaround by download the diff file to local, but by that way I don't have the diff highlighting feature like what I got in GitHub PR.
Adding .patch
at the end of the diff GitHub URL can help a bit.
Git diff 经常认为小改动是非常大的改动而没有正确识别小改动的代码。
有没有一种简单的方法可以帮助 git,比如在源代码中添加一些标记,或者其他方式?
git diff
提供了多种忽略微小变化的方法:
- -w 忽略 Ignore whitespace when comparing lines
- -b 忽略 space-更改
- custom hunk headers 检测差异时显示函数头。
这是您可以添加的最接近git diff
的提示,不是在文件本身中,而是在.gitattributes
文件中。
参见例如“Is there a way to askgit diff
to show the method name instead of the class name?”。
但是,这是针对 local diff.
对于 GitHub,当文件为 "too large".
类似的场景(仍在 GitHub)是 reported here,当看到
Sorry, we could not display the entire diff because too many files changed
I'm doing workaround by download the diff file to local, but by that way I don't have the diff highlighting feature like what I got in GitHub PR.
Adding .patch
at the end of the diff GitHub URL can help a bit.