阡陌 发表于 2023-12-18 17:47:31

git 推送报错 [remote rejected] shallow update not allowed


新建远程仓库,并将本地仓库的远程仓库改为新的地址后,执行 push 报错:
> master -> master (shallow update not allowed)

原因是之前使用了 `git clone --depth< number>` 命令进行了浅层克隆。这样一个克隆的一个限制是你不能将它推送到一个新的存储库中。

先加回旧仓库的地址:
```
git remote add old <path-to-old-remote>
```

然后执行:
```
git fetch --unshallow old
```

这个命令是认为当前本地的这个目录下面是 shallow(不完整的),比较远端库和本地库,然后把没有的下载补齐。然后就可以推到新库了。

当然了,也可以抛弃历史包袱,改成新库再推送到新远程库。



页: [1]
查看完整版本: git 推送报错 [remote rejected] shallow update not allowed