gpt4 book ai didi

github - 如何从 GitHub.com diff 干净地剪贴板复制代码?

转载 作者:行者123 更新时间:2023-12-02 06:14:18 25 4
gpt4 key购买 nike

考虑以下来自 GitHub.com 上浏览器的 Split View代码差异:

diff

在查看此差异时,我想从右侧的剪贴板复制代码(例如,为了将该代码段粘贴到另一个窗口中的不同项目中)。

但是,如果我尝试使用鼠标以通常的方式选择右侧的代码,两侧的代码最终都会被选中:

enter image description here

如果我按下 Ctrl+C/Cmd+C,我的剪贴板就会变得一团糟,其中包括两侧的代码副本> 所有 +- 指示符,这让我在粘贴后需要进行大量容易出错的手动清理工作。 (特别是当从比我在这个问题中出于说明目的而挑选的简单差异更长和更复杂的差异进行复制时!)

我的问题:如何干净、轻松地将代码从 GitHub.com 上的网络浏览器中 Split View差异的一侧复制到剪贴板?

最佳答案

2021 年 3 月更新:这一次应该受到支持:

Copy one side of split diff

When comparing changes to a file using the split view, you can now select and copy just one side of the diff.
Previously both sides were copied. Selecting over a comment will still copy the comment's contents.

split diff -- https://i1.wp.com/user-images.githubusercontent.com/7900087/110049768-5b9a1600-7d07-11eb-80eb-52ef1ada617c.gif?ssl=1

<小时/>

2018 年 5 月:

正如Hugo Giraudel所述在 his tweet 2018 年 4 月下旬,有点太快了:

GitHub finally moved the + and - symbols from diffs to CSS pseudo-elements, making it possible to copy code directly from a diff without having to clean it up.
That is long overdue and fantastic. ✨

https://pbs.twimg.com/media/DcBOo-tXcAArfD_.jpg:large

实际上...只有在第三方扩展的帮助下才能实现这一点!
喜欢sindresorhus/refined-github .

如果没有,您仍然需要复制“+”和“-”。
不过 GitLab 有这个功能。
BitBucket 仍处于待处理状态 ( issue 16204 )

timotheecour报告in the comments它对并排差异没有帮助:

the code from both sides ends up selected

这是在使用refined-github的上下文中,一个简化 GitHub 界面的浏览器扩展:issue 2765 .
2020 年 11 月更新:该问题刚刚通过 PR 3698 得到解决

https://user-images.githubusercontent.com/46634000/98137788-abd0ab00-1ec2-11eb-9e04-6f20786d5dd8.gif

关于github - 如何从 GitHub.com diff 干净地剪贴板复制代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48446463/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com