Visual Studio 2015 如何将分支合并到master?

Visual Studio 2015 How to merge a branch into master?

我是 GIT 的新手,到目前为止,我一直在使用 Visual Studio 在线 TFS 进行版本控制,我是 唯一的 开发人员。当我创建上一个项目时,我误以为 GIT 是最好的选择。

所以我登记了我的主人。然后,当我要处理一个功能时,我读到我必须创建一个分支(这在 TFS 中不是必需的)所以我创建了 "development_print" 作为一个新分支并处理我的功能。

现在我的功能已经完成,但我不知道如何将它合并回 master。我目前对多个分支不感兴趣,只想将我的新功能合并到 master 中并保留在 master 中。

在 VS 中有一个 merge branch 选项,但它只允许我合并到 development_print(我希望我的功能成为 master!)所以它不允许我设置为当前分支并从分支合并显示:

哪个有点令人困惑?似乎都倒退了。那么,如何在不丢失我在该功能上所做的所有工作的情况下摆脱困境?

您可以按照微软教程“Create work in branches”进行操作。
此外,如 Jeremy Bytes 的“Getting Used to Git in Visual Studio: Branches”(2014 年,但仍应适用)所示,您可以返回到 "Branches" 部分和 select "Merge"。

This gives us drop-downs to fill in:

您可以在“Microsoft Application Lifecycle Management”中看到分支部分,在您创建主题分支时也会使用:

将development_print分支合并到master分支的方法如下:

VS -> 团队资源管理器 -> 分支 -> 双击主分支 -> 合并 -> select development_print 从分支合并 -> 合并。

select框显示:

development_print
master
origin/development_print
origin/master

这意味着您有分支 development_printmaster 用于本地和远程。 origin/ 表示远程存在分支。

如果你不想要合并后的 development_print 分支,你可以为本地和远程删除它:

团队资源管理器 -> 分支 -> select development_print -> 右键 -> 删除 -> remotes/origin 下的 select development_print -> 删除从远程分支。

在 VS 中切换到 master 分支作为您当前的分支,然后从团队资源管理器 -> 分支中您应该以正确的顺序获得合并选项,您将能够 select 在 "Merge from branch" 下拉 development_print 分支和 "Into current branch" 字段将预先 select 与 master.