【问题标题】:Git Sync to upstream: Newly created branch not showing in my forkGit 同步到上游:新创建的分支未显示在我的 fork 中
【发布时间】:2015-07-19 19:46:51
【问题描述】:

我有两个遥控器 - origin 指向我的 fork 和 upstream 指向公司 repo。

$git remote -v    
    origin  https://github.com/me/app.git (fetch)
    origin  https://github.com/me/app.git (push)
    upstream    https://github.com/company/app.git (fetch)
    upstream    https://github.com/company/app.git (push)

我在一个月前分叉了。我一直在推动起源,然后向上游提出拉取请求。这很好。

现在有人在上游创建了一个名为“3D_Theory”的分支,我想首先将该新分支反映到我的原点,然后从该分支开始工作。但由于某种原因,该分支没有反映在我的起源中。

我尝试了以下方法:

git remote show origin
>> does not list 3D_Theory

git remote show upstream
>> lists 3D_Theory

我试过了:

git fetch upstream
git checkout master
git merge upstream/3D_Theory

但我仍然没有在我的 fork 上创建那个分支。如何在上游建立一个新分支来反映我的 fork?

谢谢

以下类似问题都没有帮助我:

【问题讨论】:

标签: git github version-control git-merge git-fork


【解决方案1】:

是的,我想这行得通。

git fetch upstream 3D_Theory:3D_Theory

git status

git push origin 3D_Theory

如果您有更好的解决方案,请在此处发布,我会尝试您的解决方案并将其标记为更好的答案。

【讨论】:

    【解决方案2】:

    上面将只获取指定的分支。如果团队规模很大,可能会创建许多新分支。这可以通过以下步骤来完成。

    1. 这将获取所有上游分支并在终端上显示

      git fetch upstream

    2. 这会将当前分支推送到上游

      git push origin

    【讨论】:

    • 在分叉一个组织的 repo 后,这对我不起作用,该 repo 除了默认分支之外还包含一个分支。我无法让git fetch upstream 给我一个对所述非默认分支的引用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-01-14
    • 1970-01-01
    • 2016-01-12
    • 2020-09-16
    • 2016-01-27
    • 2016-07-16
    • 1970-01-01
    相关资源
    最近更新 更多