微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

如何使用本地历史记录更新我的远程“源/主” 如果要保留在 remote/master 上的提交应该最后出现:如果要在 remote/master 上保留的提交应该在开始时出现:

如何解决如何使用本地历史记录更新我的远程“源/主” 如果要保留在 remote/master 上的提交应该最后出现:如果要在 remote/master 上保留的提交应该在开始时出现:

上下文:

没有其他人提交过。

我创建了一个分支以在某一时刻恢复,然后继续进行编辑。 我的本地 Master 和本地历史记录目前是我想要在 repo 中生活和记住的“真相”。

但是,当我尝试推送它时,它被远程 Origin/Master 拒绝,然后我尝试拉动它,它也失败了(见截图)。

我真的很想保留我的本地历史记录并远程保存,仅此而已。

谢谢你的光芒!

enter image description here

解决方法

是否要保留 remote/master 上的以下提交:

* Lots of search..
* Replace all..
* Replace all..
* Committing additional ..
* Committing all files..
* Fixes to try to restore site

如果答案是否定的并且不应该保留所有这些提交,那么只需执行以下操作:

git checkout master // To make sure you are on the local master branch
git push -f // Force push your local master to remote/master

如果答案是 YES 并且所有这些提交都应该被保留,那么您首先需要将 rebase local master 放到 remote/master 上,如下所示:

如果要保留在 remote/master 上的提交应该最后出现:

git checkout origin/master // To make sure you are on the remote/master branch
git rebase master // we rebase remote/master to local master
                  // At this point,you might have some conflicts so follow the
                  // guide the rebase offers to resolve them
git push -f       // Force pushing the remote/master

如果要在 remote/master 上保留的提交应该在开始时出现:

git checkout master // To make sure you are on the local branch
git rebase origin/master // we rebase local master to remote master
                  // At this point,you might have some conflicts so follow the
                  // guide the rebase offers to resolve them
git push -f       // Force pushing the local master

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。