何亚斌

Remote rejected (shallow update not allowed) after changing Git remote URL
Remote rejected (shallow update not allowed) after changi...
扫描右侧二维码阅读全文
14
2019/01

Remote rejected (shallow update not allowed) after changing Git remote URL

Remote rejected (shallow update not allowed) after changing Git remote URL


一、问题描述

本人工作过程中将全志 H3 的 Linux SDK 提交到本地 gitlab 服务器上时,出现“ Remote rejected (shallow update not allowed) after changing Git remote URL ”这样的错误信息。
导致修改后的 Linux SDK 无法提交至公司本地搭建的 git 服务器。


二、解决方法

1. 若原始 git remote URL 不存在则需要添加原来的 git remote URL ,若存在则直接进行第2步

git remote add old_upstream <path-to-old-remote>

2. 获取原来的 git remote URL 的资源

git fetch --unshallow old_upstream

3. 再重新提交到新的 git remote URL

git push

三、操作解释

解决方法中 old_upstream 为待提交本地仓库的原始远程仓库,根据自己的实际情况替换,不清楚可以使用如下命令查看是否存在原始远程仓库。若除当前待提交的远程仓库外还存在原始远程仓库,则使用对应原始远程仓库名称替换;若不存在则使用与当前待提交的远程仓库名称不重复的名称来添加原始远程仓库地址即可:

git remote -v

解决方法中 <path-to-old-remote> 为待添加的原始的远程仓库地址。

Last modification:February 25th, 2019 at 10:34 pm

Leave a Comment