【问题标题】:git pull no tracking info for my branch after merging a branch from another remote to my branch将分支从另一个远程分支合并到我的分支后,git pull no tracking info for my branch
【发布时间】:2020-02-22 10:37:38
【问题描述】:

我和我的同事forked 有一个名为main_repo 的存储库。因此,我的同事在她的 fork 上创建了一个名为 new_changes 的分支,并从我的名为 my_branch 的分支中分支出来并进行了新的更改。昨天我使用合并按钮将她的分支请求合并到我的分支。

在她的拉取请求页面上,它在提交 1234 中显示 MERGED her_fork_repo new_changesmy_branch。假设如果我在我的 intellij 分支上 git pull 我会看到我同事的新更改,但它却说:

There is no tracking information for the current branch.
Please specify which branch you want to rebase against.
See git-pull(1) for details.

    git pull <remote> <branch>

If you wish to set tracking information for this branch you can do so with:

    git branch --set-upstream-to=origin/<branch> my_branch

当我输入git remote 时,从我的分支显示origin。我也尝试过git pull origin my_branch,但git 显示Already up to date

my_branch 的拉取请求页面(合并到main_repo),我也没有看到新的更改,我应该怎么做才能使新的更改反映在我的分支上?

【问题讨论】:

  • 当你说“我和我的同事分叉”时,你的意思是你和你的同事是一个分叉还是两个各自的分叉? “我将她分支的拉取请求合并到我的分支”,你的意思是拉取请求被合并到她的分叉上吗?
  • 你能分享你在运行git remote -v时看到的内容吗?
  • “我和我的同事分叉”意味着我和我的同事分别有 2 个分叉“我将她的分支的拉取请求合并到我的分支”意味着 PR 已合并到我的分叉,但那是我的错误,它实际上已合并到 main_repo 当我运行 git remote -v 我看到 origin link-to-my-fork-repo (fetch) origin link-to-my-fork-repo (push) 无论如何问题现在解决了,谢谢!

标签: git github git-pull


【解决方案1】:

在她的拉取请求页面上,它说 MERGED her_fork_repo new_changes to my_branch in commit 1234

PR 可以位于同一存储库的两个分支之间,也可以位于复刻存储库的分支与被复刻的上游原始存储库之间。

如果您的同事 PR 已合并,请确保它在哪里:它位于原始上游存储库中,您需要将该上游远程 URL 添加到您自己的本地克隆中以便能够获取“提交 1234”。

 cd /path/to/local/clone/of/my/fork
 git remote add upstream https://url/upstream/original/repository
 git fetch upstream
 git merge upstream/my_branch

【讨论】:

    【解决方案2】:

    感谢@VonC 这让我意识到我合并了指向 main_repo 而不是我的 fork repo 的同事的 PR。所以现在在main_repo 和我的fork repo 上有一个同名的分支my_branch。我所做的是我

    git remote add main https://git-link-for-main-repo
    git pull main my_branch
    

    然后修复任何合并冲突

    git add src/main/resources/conflicted_file.py
    git commit
    git push origin my_branch
    

    【讨论】:

      猜你喜欢
      • 2020-04-04
      • 1970-01-01
      • 2014-06-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-11-09
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多