How to merge all the content of a branch to another branch?

10,124

Solution 1

To me, it sounds like you're not pushing the correct (or all) branches to BitBucket. Here is a complete example of how it's done:

  1. Let's assume you have a repository with two branches: master and release. You do development on the master branch and only do releases on the release branch. It will then look something like this:

    SourceTree - merge branches

    When you want to merge the master branch into the release branch you checkout the release branch (right click on it and choose Checkout release...). Then right-click on the branch you want to merge into the release branch (master) and choose Merge master into current branch. The result is this:

    SourceTree - master branch merged into release branch

  2. You now have to push the changes to BitBucket. Click on the Push button in the toolbar. The following dialog will pop up:

    SourceTree - pushing changes dialog

    You now have to choose the branches you want to push. If you don't push a branch it will not end up on BitBucket. In this case, I want both my branches to be there so I'll tick both the Push? checkboxes. On BitBucket it will now look like this on the Branches page:

    BitBucket - Branches page

    You will also see the remote branches in SourceTree under the remotes dropdown.

What you're most likely doing wrong is that you're not pushing the release branch to BitBucket.

Solution 2

Follow this step-by-step process:

MERGE ONE BRANCH INTO ANOTHER

Branch B is new branch and we want want branch A code in B
  1. Select A take pull to stay updated.
  2. Select B select merge, merge from log.
  3. select A from first column in pop down select latest commit.
  4. commit merge immediately f no conflicts check box selected, select Ok
  5. Resolved xcproject conflicts in editor. >> <<

You have A changes in B

Share:
10,124
Steven
Author by

Steven

Updated on July 08, 2022

Comments

  • Steven
    Steven almost 2 years

    I'm new to the world of git, and also to Atlassian and SourceTree, so I've very basic about this. What I want achieve is that:

    Suppose that I've a branch called master, which I develop my application with all new features and bugfix, and another branch called release, what I want to do is merge all the content of the master branch, to ther release branch.

    What I did so far:

    1. Selected the master branch on the branches view on the left of SourceTree

    2. Clicked on the join button on the header of SourceTree and then on Ok.

    3. Clicked on the Send button on the header of SourceTree.

    After the step 3, nothing happen, in my BitBucket repository I doesn't see any Release branch, I've actually created this branch on SourceTree only. Someone could tell me what am I doing wrong?

    Thanks.

  • Steven
    Steven about 6 years
    thanks for the very clear explaination :) you're right I pushed the new branch on BitBucket and now working, but I've a question: when I click on the branches tab available to the left panel of Bitbucket, the branches window will be opened, I see as Filter "Active" and "Merged". I can see the release branch only when I click on Merged, what does mean Active? And why the release branch is only available on Merged and not on Active? Thanks again.
  • Mika Sundland
    Mika Sundland about 6 years
    @johnn You will see the release branch in the Active filter when it's "ahead" of the master branch. In my second picture, you can see that the release branch one commit ahead of the master branch. When it's not ahead anymore you can find with the Merged filter. If you see it under Merged then you might have merged the release branch into the master branch, instead of the other way. For example like this. After doing the merge in the picture the release branch was moved to the Merged filter.
  • Steven
    Steven about 6 years
    Ok I need to do some practice with these things, where did you learn this? Did you use the source tree documentation or is there a guide for basic users? thank you.
  • Mika Sundland
    Mika Sundland about 6 years
    @johnn I use Git and SourceTree both for work and for hobby projects. SourceTree is just a GUI for Git, so following any Git tutorial should work. Instead of typing out the commands you push buttons instead. The principle is the same. In the beginning, one only needs to be able to commit, push, pull and branch. Anything else can easily be googled when that time comes.