在 GitHub 上查看没有空格更改的提交
有没有办法在 github.com 上显示提交而不显示空白更改?
有没有办法从控制台显示它?即克隆然后查看本地提交(树),忽略所有空白更改?
我广泛使用 Trac;我正在寻找类似于忽略空白更改
的内容(可以在更改集视图上找到)。
Is there a way to display a commit on github.com without showing whitespace changes?
Is there a way to display that from console? i.e. clone and then look at commit (tree) locally ignoring all white space changes?
I use Trac extensively; I'm looking for something similar to Ignore White space changes
(which can be found on the changeset view).
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
将
?w=1
附加到任何显示差异的 github.com 页面上的 URL,它将忽略空格。请参阅这篇博文。Append
?w=1
to the URL on any github.com page that is showing a diff and it will ignore whitespace. See this blog post.为此,您可以在命令行(使用任何 git 的 diff 命令)使用三个选项:
--ignore-space-at-eol
忽略 EOL 时空格的更改。-b, --ignore-space-change
忽略空白量的变化。这会忽略行尾的空白,并认为一个或多个空白字符的所有其他序列是等效的。-w, --ignore-all-space
比较行时忽略空格。即使一行有空格而另一行没有空格,这也会忽略差异。我不相信 github 已经使用这些选项实现了任何东西。
There is a trio of options that you can use at the command line (with any of git's diff commands) for this:
--ignore-space-at-eol
Ignore changes in whitespace at EOL.-b, --ignore-space-change
Ignore changes in amount of whitespace. This ignores whitespace at line end, and considers all other sequences of one or more whitespace characters to be equivalent.-w, --ignore-all-space
Ignore whitespace when comparing lines. This ignores differences even if one line has whitespace where the other line has none.I don't believe github has implemented anything using these options.
遗憾的是,X 的东西消失了,之前的代码片段也变得毫无用处。现在应该可以使用以下内容:
Sadly the X thing is gone and alongside the previous snippet is rendered useless. Here is something that should work for now:
在查看提交页面的源 HTML 后,我发现 github 用“x”CSS 类标记纯空白更改...这使得以下 oneliner 成为可能:它
的作用是遍历提交表的所有行,并隐藏给定行及其后的行中确实包含“.x”元素的行。
这是完整的 JS:
After looking into source HTML of commit page, I've found out that github marks pure whitespace changes with "x" CSS class... Which makes the following oneliner possible:
What it does, is runs through all rows of the commit table, and hides rows if given line and the one after that do have ".x" element in them.
Here's full JS: