Ads Top

How to merge branch with main or master in github?

 Merge branch to master: For example we need to merge footer branch with main in github. Main branch has been updated from the other branch as header branch updated.

First we need to up to date main branch:

>> git checkout main

>> git pull origin main

Then we need to user and password then we will check updated code on the main branch.

>> git status

Need to check your code on the vs code, compare code from the remote and local. If You will found code up to date then we need to checkout on the footer branch now we are merging code from main branch to footer branch:

>> git checkout footer

>> git rebase main

(Rebase: means merge code)

Now we are going to other branch rightSidebar it’s branch found some confliction then we need to use  git add .

When git found any rebase then need to add (hp@DESKTOP-QDGCSKB MINGW64 /d/other/class/javascript (rightSidebar|REBASE 1/1)


git add .

then : git rebase –continue

When found this message: (Successfully rebased and updated refs/heads/rightSidebar.


Then need to use again : git add .   > git commit –m “Added some message related your work”    > git push origin branchname(rightSidebar)

$ git push origin rightSidebar

Logon failed, use ctrl+c to cancel basic credential prompt.


 ! [rejected]        rightSidebar -> rightSidebar (non-fast-forward)

error: failed to push some refs to ''

hint: Updates were rejected because the tip of your current branch is behind

hint: its remote counterpart. Integrate the remote changes (e.g.

hint: 'git pull ...') before pushing again.

hint: See the 'Note about fast-forwards' in 'git push --help' for details.


You will found error need to pull live code because your live code is different and now your local code is merged with main code so need to pull:

git pull origin rightSidebar

 And merge with local then resolve all types confliction then again use same process git add. > git commit –m “message” > git push origin brachname(rightSidebar)

Because need to create version of the updation otherwise we can not use history of the code.

No comments:

Copyright Reserved to Anything Learn. Powered by Blogger.