在添加远程仓库的时候,直接删除了旧的仓库。然后添加了新的地址,再次push的时候,报了[remote rejected]
错误.
查阅了网上相关资料,参考博客
这是由于之前使用了git clone --depth< number>
命令进行了浅层克隆。这样一个克隆的一个限制是你不能将它推送到一个新的存储库中。
所以需要先执行unshallow 。
先添加原来旧仓库的地址。
git remote add old< path-to-old-remote> ;
然后用git fetch
来获取旧仓库中的内容。
git fetch --unshallow old
注意:
--unshallow 可以删除旧的远程仓库。