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
How to merge develop branch to master branch within SourceTree?
提问by q0987
I have created a local git repository in C:\temp\ConsoleApplication1
. Then I click the Git Flow
button 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 分支。实现这一目标的正确方法是什么?
I have tried to select develop
branch, then click Merge
button. 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
- Checkout
master
- Click Merge button and Merge dialog opens
- Select commit with message "add line 1" and click OK
- 查看
master
- 单击合并按钮并打开合并对话框
- 选择带有消息“添加第 1 行”的提交,然后单击“确定”
Not entirely clear in the question, but did you try this already? The key step is making sure you currently have master
checked 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。
回答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
You must firstly
commit
andpush
you changes in local development in origin/development.You
merge
your changes from local development intolocal master
(create above)From there
commit
andpush
into you remote master branch
你必须首先
commit
和push
你改变起源/发展的本地发展。您
merge
从本地开发更改为local master
(上面创建)从那里
commit
,并push
为您的远程主分支
回答by OneXer
- Within SourceTree, switch your working copy to the local/branch
- Merge the changes from the remote/master using SourceTree or git command prompt
- Resolve conflicts using Sourcetree or external text editor.(save changes to yours that you want to keep, discard remote conflict)
- Commit and push the changes to remote/branch
- 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)
- 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.
- 在 SourceTree 中,将您的工作副本切换到本地/分支
- 使用 SourceTree 或 git 命令提示符合并来自远程/主服务器的更改
- 使用 Sourcetree 或外部文本编辑器解决冲突。(保存您想要保留的更改,丢弃远程冲突)
- 提交并将更改推送到远程/分支
- 在 GitHub web UI 上,切换到相关分支,然后创建一个新的 pull request(如果所有冲突都没有解决你将无法创建一个 pull request)
- 管理员将收到拉取请求的通知,并且将接受更改或请求更改。如果没有管理员设置,拉取请求将自动合并。