Ric*_*rez 13 git git-diff git-fetch git-difftool visual-studio-code
大家好,我的问题是关于git diff
,我想知道如何git diff master origin/master
在VSCODE终端上的命令中以文件形式查看,我git fetch
从远程存储库中执行了一个操作,现在我想查看差异,但命令仅显示我在航站楼。我正在努力得到这样的东西...
我想要的例子:
Rat*_*mar 19
在左侧的VSCODE中,有一个git图标,看起来像这样:
通过单击此图标,您可以在两侧看到git差异。
lbo*_*yel 12
您可以通过以下方式在 Visual Studio Code 中实现此目的
小智 8
这是查看自上次提交(在当前分支上)以来所做更改的简单方法:
经过数小时的搜索、安装和卸载扩展,这似乎已经在 VSC 中实现了。
然后通过单击...右上角的图标 - “打开文件”返回仅查看文件,而不查看更改
请注意,并排比较并不总是最好的选择。
考虑microsoft/vscode
问题 123111:允许条件并排或内联 diffEditor。
我喜欢并排差异。我对内联差异也很满意。
我不喜欢的是发现自己在狭窄的编辑器窗口中查看并排的差异:
此问题已由PR 189304和 VSCode 1.82(2023 年 8 月)的一部分解决
动态布局
如果 diff 编辑器的宽度太小,编辑器会自动切换到内联视图。
如果编辑器再次足够宽,则恢复之前的布局。设置“
diffEditor.useInlineViewWhenSpaceIsLimited": false
以禁用此行为。
~/.gitconfig
在 Visual Studio Code 中打开文件:
code ~/.gitconfig
Run Code Online (Sandbox Code Playgroud)
复制以下几行~/.gitconfig
:
[diff]
tool = default-difftool
[difftool "default-difftool"]
cmd = code --wait --diff $LOCAL $REMOTE
Run Code Online (Sandbox Code Playgroud)
保存更改。通过运行Ctrl+ Shift+ `在 Visual Studio Code 中打开一个终端。在终端中运行以下命令:
git difftool master origin/master
Run Code Online (Sandbox Code Playgroud)
If you want to diff changes from different branches. For example you want to see all the changes from last N commits in your Feature branch.
[diff]
tool = vscode
[difftool "vscode"]
cmd = code --wait --diff $LOCAL $REMOTE
Run Code Online (Sandbox Code Playgroud)
Go to your git project. Type in: git difftool {{branch you want to check with}}, for exmaple git difftool master
You will be prompted for each file, if you want to open it in VSCode or no.
我在这里回答了一个类似的问题。
但基本上你可以使用以下命令:
git difftool -x "code --wait --diff"
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
12478 次 |
最近记录: |