简体   繁体   English

将更改推送到github中的另一个分支

[英]Push changes to another branch in github

Silly question, but i need help. 愚蠢的问题,但我需要帮助。

There are two branches in the same repository in git-hub. 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'. A和BI已经克隆了分支A,我进行了一些更改,现在我想将更改推送到分支B.随着'git status',我可以看到我的分支与'origin / A'是最新的。 Should i add and commit the changes and then just 'push' to 'origin/B'? 我应该添加并提交更改然后“推送”到'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. 我该怎么做才能将更改推送到正确的分支(B)而不是A?我不想替换A分支中的任何内容。

This should work: 这应该工作:

  • switch on branch B : 打开B分支:

     git checkout B 
  • merge A in B B合并A

     git merge A 
  • push the changes 推动变革

     git push origin B 

You just need to do git push origin frombranch:tobranch 你只需要做一个git push origin frombranch:tobranch

EDIT after looking at your clarifying comments: git checkout branch-b; 看完你的澄清评论后编辑: git checkout branch-b; git merge branch-a

assuming you have origin\\branch-a and is updated. 假设您有origin\\branch-a并且已更新。

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. 如果A是最新的,并且是你的起源,那么结帐分支B只需要执行git merge origin,B将更新所有A的最新更改。 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. 如果要在合并原点(A)之前先检查,请执行git fetch origin然后执行git log -p HEAD..origin以查看要合并的更改。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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