How to merge branch to master?
To merge branch with master,there are two ways you can proceed
- By Git commands
- By Github Dashboard
Git Commands
Here also you can go with two different commands,first is
- checkout to your master branch using
git checkout master
- pull your latest code from the branch you want to merge,use
git pull --rebase origin branch_name
. It may give you some conflicts which you can resolve by usinggit status
,after resolving you can check if any conflict is more there or not by usinggit rebase --continue
.
Second way
- To master you can cherrypick the commits from the branch you want to
merge
git cherry-pick <commit id>
.If you are getting conflict usegit cherry-pick --continue
.
Actually this is the more suggested way you can proceed.
Merge branch using GitHub Dashboard
This is most easiest way to merge. Create new pull request, select the branch you want to merge and resolve the conflicts.
If you want to merge your branch to master on remote, follow the below steps:
- push your branch say 'br-1' to remote using
git push origin br-1
. - switch to master branch on your local repository using
git checkout master
. - update local master with remote master using
git pull origin master
. - merge br-1 into local master using
git merge br-1
. This may give you conflicts which need to be resolved and changes committed before moving further. - Once merge of br-1 to master on local is committed, push local master to remote master using
git push origin master
.