简体   繁体   中英

Push changes to another branch in github

Silly question, but i need help.

There are two branches in the same repository in git-hub. A and BI have cloned the branch A, i made some changes and now I want to push the changes to branch B.With 'git status' i can see that my branch is up-to-date with 'origin/A'. Should i add and commit the changes and then just 'push' to 'origin/B'?

What can I do to push the changes to the correct branch(B) and not A?I don't want to replace anything in the A branch.

This should work:

  • switch on branch B :

     git checkout B 
  • merge A in B

     git merge A 
  • push the changes

     git push origin B 

You just need to do git push origin frombranch:tobranch

EDIT after looking at your clarifying comments: git checkout branch-b; git merge branch-a

assuming you have origin\\branch-a and is updated.

If A is up to date, and is your origin, checkout branch B and just do git merge origin and B will be updated with all A's latest changes. If you want to check first before merging origin (A), do git fetch origin then do git log -p HEAD..origin to see the changes you are going to merge.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM