【问题标题】:Git replacing current remote branch with masterGit用master替换当前远程分支
【发布时间】:2016-07-24 13:44:58
【问题描述】:

我觉得我知道该怎么做,但我做不到。

我正在尝试创建 github 页面。在远程来源我有 2 个分支:master 和 gh-pages。

我不小心用我不想要的更新更新了远程 gh 页面;我希望我的远程 gh 页面看起来与远程主机或本地主机完全相同。 (我的本地主机与远程主机是最新的)。问题是,当我尝试拉 gh-pages 时,它与我的本地 master 冲突。

如何用远程/本地主机替换远程分支 gh-pages? (授予当前远程 gh-pages 与远程/本地主机冲突)

Blah-Air:SomeBranch blablah$ git pull origin gh-pages
remote: Counting objects: 15, done.
remote: Compressing objects: 100% (13/13), done.
remote: Total 15 (delta 1), reused 15 (delta 1), pack-reused 0
Unpacking objects: 100% (15/15), done.
From https://github.com/SomeGitHub/SomeBranch
 * branch            gh-pages   -> FETCH_HEAD
 * [new branch]      gh-pages   -> origin/gh-pages
Auto-merging index.html
CONFLICT (add/add): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.

^ 如您所见,我需要解决冲突,但不知道如何解决。

【问题讨论】:

    标签: ruby-on-rails github github-pages


    【解决方案1】:

    首先,如果您希望远程始终与master 分支同步,您可能不应该在本地gh-pages 分支上进行开发。如果我不在不同的分支上开发,我觉得我会犯和你一样的错误。

    但要摆脱这种情况,您可以使用git reset --hard HEAD^ 返回父提交,然后使用git push origin gh-pages -f 强制推送指向正确提交的分支。如果您想将该提交保留在您的本地gh-pages,然后尝试强制将您的本地master(应该已经在正确的提交中)推送到您的远程gh-pages

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-10-19
      • 1970-01-01
      • 2011-02-15
      • 2012-07-25
      • 2013-03-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多