如何在没有优点和缺点的情况下复制 GitHub 中的部分提交差异?

How do I copy part of a commit diff in GitHub without the pluses and the minuses?

我经常需要复制并粘贴 GitHub 提交的一部分。然而,每当我这样做时,我发现自己手动向下移动每一行并点击 Delete 以去除所有 +/- 符号。

是否有更方便的方法将 GitHub 提交的一部分复制到剪贴板?
欢迎提出涉及 Chrome extensions/your 个人项目的建议。

Update July 2018:

Unselectable diff markers

The + and - diff markers are no longer copied to your clipboard when you copy the contents of a diff.

耶!


原始答案(2017 年 8 月)

你可以:

  • curl the diff itself from GitHub(不克隆所有回购历史):

    https://github.com/foo/bar/commit/${SHA}.patch
    
  • :

    .... | sed -r "s/^([^-+ ]*)[-+ ]/\1/" | less -r