【问题标题】:"force" git commit on local to external via push? [duplicate]通过推送将本地“强制”git提交到外部? [复制]
【发布时间】:2011-05-15 22:12:36
【问题描述】:

可能重复:
Github first push problem… how to merge remote changes?

我的外部仓库已经过时了。我想将我所有的本地更改推送到上游。但是,当我尝试这样做时,我收到以下消息...

error: failed to push some refs to 'ssh://mylink'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again.

我不想拉,因为如果我这样做,那些外部更改会弄乱我的本地更改。如何覆盖外部?

【问题讨论】:

  • 其他人在使用远程仓库吗?

标签: git


【解决方案1】:

git push --force remoterepository

【讨论】:

  • 要非常非常小心 - 如果那些“外部”更改(远程提交而不是本地存储库中的提交)只是您很久以前的提交,那么您已经替换了它,这很好。但如果它们是别人的作品,你会通过推动将其扔掉 - 在这种情况下,你确实需要在推动之前拉动和协调。
【解决方案2】:

简单地覆盖你的远程仓库怎么样?

【讨论】:

    【解决方案3】:

    在我看来,这是 git 的受保护机制。 因为,有人在你之前推动了某事,所以你需要拉他的声誉并建立你的本地更改,以确保没有冲突。 所以也许你应该先尝试拉别人的声誉,然后再推动你的改变。

    【讨论】:

      猜你喜欢
      • 2017-02-20
      • 1970-01-01
      • 2015-10-16
      • 2015-10-02
      • 2013-11-25
      • 2021-07-07
      • 2013-04-25
      • 2017-02-24
      • 2021-12-19
      相关资源
      最近更新 更多