简体   繁体   中英

How to merge develop branch to master branch within SourceTree?

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.

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

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?

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

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.

  1. Checkout master
  2. Click Merge button and Merge dialog opens
  3. Select commit with message "add line 1" and click OK

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

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 , eg "master" (double click on the branch on the left in Sourcetree under "Branches).

Next, just right-click on the branch you want to merge into your current branch (eg "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.

在此处输入图像描述

As you said you are using git flow, the right way to merge develop into master is to start a new release branch.

After you have run tests on the release branch by finishing release it would merge on both develop and master to bring all the latest changes to the branches. Also they have a guide smarter branching with sourcetree on their blog.

  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.

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

In Git command line:

 git push -u origin master
  1. You must firstly commit and push you changes in local development in origin/development.

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

  3. From there commit and push into you remote master branch

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM