-1

I have a branch called B1. I want to merge some files from the B2 branch and I want to commit them. How can I merge with other branch details?

2
  • Did you try git merge B2? Did you have any problems? It's kind of a very basic operation that shouldn't have given you any problems. If you did have problems, could you explain what they were? Did you want to selectively merge only some of the commits from the B2 branch into B1, instead of all of them?
    – user456814
    Aug 12, 2013 at 5:06
  • Did you only want to merge individual files, instead of entire commits? If so, then How to merge specific files from Git branches may be of interest to you.
    – user456814
    Aug 12, 2013 at 5:15

1 Answer 1

1

To merge a branch in Git, do the following:

git checkout B1
git merge B2

To learn more about branching in Git, see Git Branching. To learn more about Git basics, I highly recommend the FREE online Pro Git book, in particular chapters 1-3, 6-6.5.

If you only wanted to merge some of the commits from the B2 branch, you have the option of using git cherry-pick <sha-of-commit>. If instead you want to take only the changes to a particular file X in B2, then you could use checkout, as explained in this answer to How to merge specific files from Git branches:

git checkout B1
git checkout B2 X

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.