Git merge two local branches
The answer from the Abiraman was absolutely correct. However, for newbies to git, they might forget to pull the repository. Whenever you want to do a merge from branchB into branchA. First checkout and take pull from branchB (Make sure that, your branch is updated with remote branch)
git checkout branchB
git pull
Now you local branchB is updated with remote branchB Now you can checkout to branchA
git checkout branchA
Now you are in branchA, then you can merge with branchB using following command
git merge branchB
If I understood your question, you want to merge branchB
into branchA
. To do so,
first checkout branchA
like below,
git checkout branchA
Then execute the below command to merge branchB
into branchA
:
git merge branchB
Here's a clear picture:
Assuming we have branch-A and branch-B
We want to merge branch-B into branch-A
on branch-B -> A: switch to branch-A
on branch-A: git merge branch-B