Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 853
Steven Avatar asked Jan 25 '18 20:01

Steven


People also ask

How do I pull data from one branch to another in git?

After running the stash command for a branch, if the git user wants to pull the branch's changes to another branch, it can be done easily by using the `git stash pop` command that works like the `git merge` command.

How do I merge changes from one branch to the main?

First we run git checkout master to change the active branch back to the master branch. Then we run the command git merge new-branch to merge the new feature into the master branch. Note: git merge merges the specified branch into the currently active branch.


2 Answers

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.

like image 63
Mika Sundland Avatar answered Nov 03 '22 00:11

Mika Sundland


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

like image 33
Abhi Avatar answered Nov 02 '22 23:11

Abhi