我使用 Visual Studio 源代码管理在 Git 中创建了一个功能分支。
现在我想使用 Visual Studio Code 将功能分支 merge 到 master 中。
执行此操作的正确过程是什么?
最佳答案
开始 VS 代码 1.48 ,许多 Git 命令现在可以作为源代码控制面板的菜单选项使用,包括 merge 分支。见 "New Git View submenus" section of the July 2020 (1.48) release notes :
Thanks to the new submenu proposed API, the Git View and More Actions (...) menu has been refactored for better organization of several commands:
merge 分支(例如 merge featureA 到 master):
...
> Checkout to...
...
> Branch
> Merge Branch...
...
> Pull,Push
> Push
VS Code 1.48 之前 , VS Code Source Control 没有用于 merge 分支的 UI。但是您可以使用来自 Command Palette 的命令进行 merge 。 .
merge 分支(例如 merge my-feature-branch 到 master ):
虽然使用 VS Code 源代码控制 UI 可以工作,但我强烈建议学习如何从命令行使用 Git,因为它们使用起来更简单,但它们可以让您更好地控制 Git 操作。另外,它们甚至可以在 VS Code 之外工作,只要您可以访问终端。
例如,可以从终端执行相同的分支 merge 操作。
$ git checkout master
$ git pull
$ git merge my-feature-branch
$ git log
commit 54971a1cc845459742392061e71ef4fcb2444357 (HEAD -> master)
Merge: e8fad11 b1d9050
Author: XXX
Date: Wed May 13 20:14:15 2020 +0900
Merge branch 'my-feature-branch'
...
了解 Git 的最佳地点在这里:https://git-scm.com/book/en/v2 .专用于
git merge
:关于Git:如何使用 VS Code 源代码管理将功能分支 merge 到 master 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61755744/