git 如何在 SourceTree 中将开发分支合并到主分支?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34687089/
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 03:49:58  来源:igfitidea点击:

How to merge develop branch to master branch within SourceTree?

gitatlassian-sourcetree

提问by q0987

I have created a local git repository in C:\temp\ConsoleApplication1. Then I click the Git Flowbutton and follow by OK to accept all default settings. Now under the branches, I can see develop and master.

我在 .git 中创建了一个本地 git 存储库C:\temp\ConsoleApplication1。然后我单击Git Flow按钮并按 OK 接受所有默认设置。现在在分支下,我可以看到开发和掌握。

Next I click Git Flow again to start a new feature, then make some changes and finally finish the feature.

接下来我再次单击 Git Flow 以启动一个新功能,然后进行一些更改并最终完成该功能。

Now my branch looks as follows:

现在我的分支如下所示:

[develop] add line 1
[master] initial commit

Question: I would like to merge the develop into the master branch. What is the right method to achieve that?

问:我想将 develop 合并到 master 分支。实现这一目标的正确方法是什么?

http://i64.tinypic.com/259ye6b.png

http://i64.tinypic.com/259ye6b.png

I have tried to select developbranch, then click Mergebutton. No matter which commit I choose, there is nothing happens. I also tried to select master and see no difference.

我试图选择develop分支,然后单击Merge按钮。无论我选择哪个提交,都不会发生任何事情。我也尝试选择 master 并没有看到任何区别。

回答by dtmland

  1. Checkout master
  2. Click Merge button and Merge dialog opens
  3. Select commit with message "add line 1" and click OK
  1. 查看 master
  2. 单击合并按钮并打开合并对话框
  3. 选择带有消息“添加第 1 行”的提交,然后单击“确定”

Not entirely clear in the question, but did you try this already? The key step is making sure you currently have masterchecked out.

问题中并不完全清楚,但是您是否已经尝试过?关键步骤是确保您当前已master结帐。

回答by wickywills

Sourcetree has changed a fair bit since this question was asked, but just in case others arrive here and don't quite understand the new "Merge" button, all you need to do is checkout the branch you want to merge your changes into, e.g. "master" (double click on the branch on the left in Sourcetree under "Branches).

自从提出这个问题以来,Sourcetree 已经发生了相当大的变化,但以防万一其他人到达这里并且不太了解新的“合并”按钮,您需要做的就是检查要将更改合并的分支,例如“master”(双击“Branches”下 Sourcetree 左侧的分支)。

Next, just right-click on the branch you want to merge into your current branch (e.g. "my-new-branch") and from the right-click menu, select "Merge my-new-branch into master". This helped me coming to Sourcetree as a GitKraken user.

接下来,只需右键单击要合并到当前分支中的分支(例如“my-new-branch”),然后从右键单击菜单中选择“将my-new-branch 合并到 master 中”。这帮助我以 GitKraken 用户的身份来到 Sourcetree。

enter image description here

在此处输入图片说明

回答by Mahmud Dehkordi

I think you need to create a local "master" branch tracking your remote origin/master.

我认为您需要创建一个本地“主”分支来跟踪您的远程源/主。

In Git command line:

在 Git 命令行中:

 git push -u origin master
  1. You must firstly commitand pushyou changes in local development in origin/development.

  2. You mergeyour changes from local development into local master(create above)

  3. From there commitand pushinto you remote master branch

  1. 你必须首先commitpush你改变起源/发展的本地发展。

  2. merge从本地开发更改为local master(上面创建)

  3. 从那里commit,并push为您的远程主分支

回答by OneXer

  1. Within SourceTree, switch your working copy to the local/branch
  2. Merge the changes from the remote/master using SourceTree or git command prompt
  3. Resolve conflicts using Sourcetree or external text editor.(save changes to yours that you want to keep, discard remote conflict)
  4. Commit and push the changes to remote/branch
  5. On the GitHub web UI, switch to the relevant branch, then create a new pull request(If all conflicts are not resolved you will not be able to create a pull request)
  6. Admins will be notified of pull request and changes will be accepted or changes will be requested. If there are no admins setup, the pull request will automatically get merged.
  1. 在 SourceTree 中,将您的工作副本切换到本地/分支
  2. 使用 SourceTree 或 git 命令提示符合并来自远程/主服务器的更改
  3. 使用 Sourcetree 或外部文本编辑器解决冲突。(保存您想要保留的更改,丢弃远程冲突)
  4. 提交并将更改推送到远程/分支
  5. 在 GitHub web UI 上,切换到相关分支,然后创建一个新的 pull request(如果所有冲突都没有解决你将无法创建一个 pull request)
  6. 管理员将收到拉取请求的通知,并且将接受更改或请求更改。如果没有管理员设置,拉取请求将自动合并。