我引用https://code.visualstudio.com/Docs/editor/versioncontrol#_viewing-diffs .
有没有办法使用代码 GUI 轻松地在两个不同位置(例如工作树和特定提交)显示文件的并排差异?
在源代码管理 View 中,如果我单击更改的文件,它会显示工作树版本和(我相信)最新提交版本的并排差异。有没有办法轻松选择另一个提交?
最佳答案
来到 vscode (Insider Build v1.54) 是能够比较来自任意两次提交的文件 .它将使用上下文菜单项 Select for Compare
进行操作和 Compare with Selected
使用 Select for Compare
打开差异编辑器左边的版本。
以前,您只能将任何文件版本与当前版本进行比较。现在您可以比较来自任何两个提交的版本。
见 https://github.com/microsoft/vscode/issues/116361#issuecomment-783524802
见 https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_44.md#timeline-view对于 v1.44 信息。
在 v1.43 中,时间轴 View 在标准版本中通过下面提到的相同设置可用。
We've now added paging support (via Load more above), and added a relative timestamp over on the right. Extensions can also contribute menu items to the Timeline view as well as to individual timeline items. In the screenshot above, you can see that the built-in Git extension is contributing a few new commands: Copy Commit ID and Copy Commit Message.
新的 (v1.42) 时间轴 View 可以满足您的需求。见 https://github.com/microsoft/vscode-docs/blob/vnext/release-notes/v1_42.md#timeline-view
In this milestone, we've made progress on the new Timeline view, and have an early preview to share. This is a unified view for visualizing time-series events (for example, Git commits, file saves, test runs, etc.) for a resource (file, folder). To enable the Timeline view, you must be using the Insiders edition and then add the following setting:
"timeline.showView": true
// has been removed
Timeline
Below you can see the Timeline view displaying the Git commit history of a file:
In this early preview, the Timeline view shows the Git commit history of the active document, which is currently limited to 32 items. Selecting one of those commits will open a diff view of the changes introduced by that commit. Extensions will also be able to contribute their own timeline sources, which will be shown in this unified timeline view. Eventually, you will also be able to select (filter), which sources you'd like to see in the view.
Stay tuned, we have much more in store for this new feature. You can follow along by subscribing to issue #84297 and by watching for issues tagged with the 'timeline' label. And if you have ideas on other types of information you'd like to see in this view, let us know!
我的演示:您当前的文件始终位于左侧 - 看起来您无法更改它。所以它总是当前文件<->选择一个提交差异。不要比较两个不同的提交。
关于git - 如何使用 GUI 比较两个不同提交中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60098917/