fatal/ refusing to merge unrelated histories.md

环境

MacBook Pro

Git: 2.21.0

前言

在玩Hugo的最后一步时,因为我的GitHub以前就有代码了,所以我先执行了:

git rm -rf --cache *

之后,再按照Hugo网上的教程去推送代码时,遇到了如下的错误:

yutaodeMacBook-Pro:public yutao$ git push -u origin master 
To github.com:b3601993/b3601993.github.io.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'git@github.com:b3601993/b3601993.github.io.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.

根据提示,我得执行git pull

yutaodeMacBook-Pro:public yutao$ git pull -f origin master
warning: no common commits
remote: Enumerating objects: 45, done.
remote: Counting objects: 100% (45/45), done.
remote: Compressing objects: 100% (23/23), done.
remote: Total 153 (delta 9), reused 45 (delta 9), pack-reused 108
Receiving objects: 100% (153/153), 1.20 MiB | 518.00 KiB/s, done.
Resolving deltas: 100% (17/17), done.
From github.com:b3601993/b3601993.github.io
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> origin/master
fatal: refusing to merge unrelated histories # 错误在这

这个错误呢,官网有个图,很清晰明了:

Git

解决办法

git pull origin master --allow-unrelated-histories

参考地址:https://www.educative.io/edpresso/the-fatal-refusing-to-merge-unrelated-histories-git-error

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

山鬼谣me

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值