git - 如何使用 GUI 比较两个不同提交中的文件

标签 git visual-studio-code

我引用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 打开差异编辑器左边的版本。
以前,您只能将任何文件版本与当前版本进行比较。现在您可以比较来自任何两个提交的版本。
timeline 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.


Timeline view

新的 (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:


    Timeline demo

    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!



    我的演示:您当前的文件始终位于左侧 - 看起来您无法更改它。所以它总是当前文件<->选择一个提交差异。不要比较两个不同的提交。
    timeline demo2

    关于git - 如何使用 GUI 比较两个不同提交中的文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60098917/

    相关文章:

    node.js - 在 Visual Studio Code 中调试 Outlook 的 Web 加载项

    r - 使用 VSCode 在 Quarto Docs 中为 R block 添加键盘快捷键

    node.js - npm create-react-app 错误 : EACCES: permission denied. 该操作被您的操作系统拒绝

    visual-studio-code - 如何在 Visual Studio 代码的同一行中显示错误或建议

    git - merge 后未出现对主分支的更改

    git - 如何使用 TortoiseGit 还原特定提交?

    git - 在 Windows 中通过 "fast-export"将 Hg 迁移到 Git

    windows - 为什么 git sparse checkout 会留下目录?

    git - 使用 gitlab 实现 CI

    visual-studio-code - 如何在 VS Code 控制台中按住 Ctrl 键并单击文件链接中的文件名与其他字符?