MENU

[remote rejected] master -> master (shallow update not allowed)

September 2, 2022 • 默认分类

问题

在使用 gitea 仓库迁移时,本地 clone 时指定了 --depth=1 导致迁移到新仓库地址时报此错误。
这是由于之前使用了 git clone --depth= 命令进行了浅层克隆。这样一个克隆的一个限制是你不能将它推送到一个新的存储库中。

解决

  1. 先执行 unshallow,添加原来旧仓库的地址:
git remote add old <path-to-old-remote>
  1. 获取旧仓库中的内容
git fetch --unshallow old
  1. 重新 push
git push -f