git 将本地分支合并到 master 以外的远程分支?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/40145657/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 04:34:12  来源:igfitidea点击:

Merge local branch into remote branch other than master?

gitgithub

提问by Square-root

so I have a local branch A that doesn't exist yet in remote repo. And I have remote branch B in remote repo. How do I merge my local changes into the remote branch?

所以我有一个本地分支 A 在远程仓库中尚不存在。我在远程仓库中有远程分支 B。如何将本地更改合并到远程分支?

refer me to some links if you can.

如果可以,请给我一些链接。

回答by Frank

If branch B is at local, You can merge A to B locally and push B to remote:

如果分支 B 在本地,您可以在本地将 A 合并到 B 并将 B 推送到远程:

git checkout B
git merge A
git push origin B

If you don't have B at local, you can push A to remote and pull request to merge A to B and click mergebutton on github.

如果本地没有 B,可以将 A 推送到远程并拉取请求将 A 合并到 B,然后单击mergegithub 上的按钮。

or, fetch B branch to local and merge A to B , then push B to remote, like this:

或者,将 B 分支提取到本地并将 A 合并到 B ,然后将 B 推送到远程,如下所示:

git checkout master
git fetch orign B:B       (fetch B to local)
git checkout B            (checkout to branch B)
git merge A               (merge A to B)
git push origin B         (push merged branch B to remote)