如何将所有新的上游分支与我的 fork 同步?

Gab*_*iel 7 git github

前段时间我分叉了一个 git repo。从那以后,有几个新的提交到 master 分支。https://help.github.com/articles/syncing-a-fork/解释了如何将上游主分支与本地主分支同步,然后将这些提交推送到我的分支。

但是它没有提到如何同步新的上游分支。当我最初在 github 上 fork 项目时,它看起来像它带来了所有当时的分支。

我看过有关如何一次同步一个分支的解释。有没有办法一次同步所有新旧分支?

I haven't made any commits to my fork. Thus I am looking for a fast forward sync.

Edit: Another way to say this:

I want

git ls-remote origin
Run Code Online (Sandbox Code Playgroud)

to match

git ls-remote upstream
Run Code Online (Sandbox Code Playgroud)

This would include branches and tags.

Von*_*onC 7

但是它没有提到如何同步新的上游分支

您需要做的就是:

git fetch upstream
Run Code Online (Sandbox Code Playgroud)

这将获取或更新所有上游分支并将它们存储在您的本地存储库中,在上游命名空间中。

你可以看到这些分支:

git branch -avv
Run Code Online (Sandbox Code Playgroud)

它不允许我将所有上游分支推送到原点。

为此,您需要根据要推送到源的任何上游分支创建本地分支:

git branch abranch upstream/abranch
gut push -u origin abranch 
Run Code Online (Sandbox Code Playgroud)

在“ git - 从现有远程分支创建本地分支”中查看更多信息。

要对所有分支执行此操作,请参阅“通过它的镜像裸远程从远程拉取所有分支”。
或者,更好:“将所有远程 git 分支作为本地分支进行跟踪”。
只需使用“ upstream”代替origin。