Git:在本地合并远程分支

问题描述:

我通过 git fetch --all 来拉取所有远程分支。我可以看到我想通过 git branch -a 合并的分支作为remotes / origin / branchname。问题是它不可访问。我不能合并或签出?

I've pulled all remote branches via git fetch --all. I can see the branch I'd like to merge via git branch -a as remotes/origin/branchname. Problem is its not accessible. I can't merge or checkout?

您可以引用这些远程追踪分支〜(以 git branch -r )与他们的远程名称。

You can reference those remote tracking branches ~(listed with git branch -r) with the name of their remote.

如果您想合并您的本地分支上的其中一个远程分支: / p>

If you want to merge one of those remote branches on your local branch:

git checkout master
git merge origin/aRemoteBranch

如果您想在其中一个远程分支上合并您的本地分支,您需要首先在所述远程分支的顶部创建一个本地分支:

If you want to merge one of your local branch on one of those remote branch, you need to create a local branch on top of said remote branch first:

git checkout -b myBranch origin/aBranch
git merge aLocalBranch