1

我是 Git 的新手,在尝试解决这个问题时确实需要帮助,因为我完全不知道该怎么做。

假设我在 Github 中有两个 repo,Repo1 和 Repo2。Repo1 是我的个人 Repo,包含一个软件。Repo2 是其他东西的一部分,包含与 Repo1 相同的内容(它是一个分支)。

前段时间我设法弄乱了 Repo1,还设法用不正确的信息更新了 Repo2。在我尝试修复这两个问题时,我确实成功地修复了 Repo1,但强制使用来自 Repo1 的文件(使用 Mac 版 Github)更新 Repo2,它使用正确的文件更新了 Repo2,但完全搞砸了 Repo2 的历史。

现在我可以正确更新 Repo1,但是每当我尝试将 Repo1(上游)中的文件提取到本地 Repo2 时,都会出现合并错误。我尝试使用此处给出的解决方案: Resolve conflict using remote changes when pull from Git remote 这似乎修复了本地 Repo2(但我不确定......),但是当我尝试将结果推送到 Github 上的 Repo2 时,我收到以下错误消息:

! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/folder/Repo2.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

我不关心 Repo2 的历史;我只想用 Repo1 的内容覆盖 Repo2 的全部内容,并摆脱任何后续问题。我怎样才能做到这一点?

请帮忙,因为我发现处理这整个混乱非常令人沮丧,我不确定我在做什么。

4

2 回答 2

2

如果您只想在 repo2 获取 repo1 的全部内容,您可以尝试:

git push --mirror

您可以在github 帮助页面中找到它

于 2014-02-17T15:42:36.947 回答
0

似乎 github 上的 Repo2 领先于您本地版本的 Repo2。您需要从 github 获取和合并或获取和变基,以便再次推送到它。

于 2013-11-12T10:38:25.037 回答