git 在 Visual Studio Code 中如何合并两个本地分支?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/38648772/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:25:43  来源:igfitidea点击:

In Visual Studio Code How do I merge between two local branches?

gitvisual-studio-code

提问by TheFastCat

In Visual Studio Code it seems that I am only allowed to push, pull and sync. There is documented support for merge conflicts but I can't figure out how to actually merge between two branches. The Git command line within VSC (press F1) only facillitates a subset of commands:

在 Visual Studio Code 中,我似乎只被允许推送、拉取和同步。有文档支持合并冲突,但我不知道如何在两个分支之间实际合并。VSC 中的 Git 命令行(按 F1)仅提供了一部分命令:

eGit options available in VSCode

VSCode 中可用的 eGit 选项

Attempting to pull from a an alternate branch or push to an alternate branch yields:

尝试从备用分支拉取或推送到备用分支会产生:

git Command throttling

git 命令限制

Here's the documentation on VSCode's Git Visual Studio Code Git Documentation

这是 VSCode 的 Git Visual Studio Code Git 文档上的文档

What am I overlooking?

我在看什么?

采纳答案by VonC

Update June 2017 (from VSCode 1.14)

2017 年 6 月更新(来自VSCode 1.14

The ability to merge local branches has been added through PR 25731and commit 89cd05f: accessible through the "Git: merge branch" command.
And PR 27405added handling the diff3-style merge correctly.

通过PR 25731和提交89cd05f添加了合并本地分支的功能:可通过“ Git: merge branch”命令访问。
PR 27405添加正确处理的diff3式合并。

Vahid's answermention 1.17, but that September releaseactually added nothing regarding merge.
Only the 1.18 October one added Git conflict markers

Vahid回答提到了 1.17,但那个9 月的版本实际上没有添加任何关于合并的内容。
只有 10 月 18 日的一个添加了Git 冲突标记

https://code.visualstudio.com/assets/updates/1_18/merge.png

https://code.visualstudio.com/assets/updates/1_18/merge.png

From 1.18, with the combination of merge command (1.14) andmerge markers (1.18), you truly can do local merges between branches.

从 1.18 开始,通过合并命令(1.14)合并标记(1.18)的组合,您真正可以在分支之间进行本地合并。



Original answer 2016:

原始答案 2016 年:

The Version Control docdoes not mention merge commands, only merge status and conflict support.

版本控制文档中没有提到合并的命令,只有合并状态和冲突的支持。

Even the latest 1.3 June releasedoes not bring anything new to the VCS front.

即使是最新的 6 月 1.3 版也没有给 VCS 带来任何新的东西。

This is supported by issue 5770which confirms you cannot use VS Code as a git mergetool, because:

这由问题 5770支持,它确认您不能将 VS Code 用作 git mergetool,因为:

Is this feature being included in the next iteration, by any chance?

Probably not, this is a big endeavour, since a merge UI needs to be implemented.

是否有机会在下一次迭代中包含此功能?

可能不是,这是一项很大的努力,因为需要实现合并 UI

That leaves the actual merge to be initiated from command line only.

这使得实际的合并只能从命令行启动。

回答by Vahid

You can do it without using plugins.

您可以在不使用插件的情况下做到这一点。

In the latest version of vscode that I'm using (1.17.0) you can simply open the branch that you want (from the bottom left menu) then press ctrl+shift+pand type Git: Merge branchand then choose the other branch that you want to merge from (to the current one)

在我使用的最新版本的 vscode (1.17.0) 中,您只需打开您想要的分支(从左下角的菜单中),然后按下ctrl+shift+p并输入Git: Merge branch,然后选择您想要从中合并的另一个分支(到现在的)

回答by Shahar Kazaz

I had the same question, so I created Git Merger.
hope this helps :)

我有同样的问题,所以我创建了Git Merger
希望这可以帮助 :)

回答by Jay Culpepper

I found this extension for VS code called Git Merger. It adds Git: Merge fromto the commands.

我找到了这个名为Git Merger 的VS 代码扩展。它添加Git: Merge from到命令中。