-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?

  • 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? –  Aug 12 '13 at 05:06
  • Did you only want to merge individual files, instead of entire commits? If so, then [How to merge specific files from Git branches](http://stackoverflow.com/questions/18115411/how-to-merge-specific-files-from-git-branches) may be of interest to you. –  Aug 12 '13 at 05:15

1 Answers1

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
Community
  • 1
  • 1