问题描述
itaken@itaken-home:~/path/to/project$ git remote -v
origin http://gitlab.local/python/myproject.git (fetch)
origin http://gitlab.local/python/myproject.git (push)
itaken@itaken-home:~/path/to/project$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = http://gitlab.local/python/myproject.git
fetch = +refs/heads/master:refs/remotes/origin/master
[branch "master"]
remote = origin
merge = refs/heads/master
itaken@itaken-home:~/path/to/project$ git st
位于分支 master
您的分支与上游分支 'origin/master' 一致。
无文件要提交,干净的工作区
itaken@itaken-home:~/path/to/project$ git push -f
枚举对象: 649, 完成.
对象计数中: 100% (649/649), 完成.
使用 8 个线程进行压缩
压缩对象中: 100% (254/254), 完成.
写入对象中: 100% (649/649), 40.96 MiB | 1.99 MiB/s, 完成.
总共 649 (差异 381),复用 649 (差异 381)
remote: Resolving deltas: 100% (381/381), done.
remote: GitLab: 500 Internal Server Error
To http://gitlab.local/python/myproject.git
! [remote rejected] master -> master (shallow update not allowed)
error: 推送一些引用到 'http://gitlab.local/python/myproject.git' 失败
尝试使用git fetch --unshallow origin
, git fetch --update-shallow
修复,但是没有效果:
itaken@itaken-home:~/path/to/project$ git fetch --unshallow origin
fatal: Couldn't find remote ref refs/heads/master
itaken@itaken-home:~/path/to/project$ git fetch --update-shallow
fatal: Couldn't find remote ref refs/heads/master
itaken@itaken-home:~/path/to/project$ git fetch --unshallow upstream
fatal: 'upstream' does not appear to be a git repository
fatal: 无法读取远程仓库。
请确认您有正确的访问权限并且仓库存在。
itaken@itaken-home:~/path/to/project$ git push -u origin master
fatal: unable to get credential storage lock: 文件已存在
枚举对象: 649, 完成.
对象计数中: 100% (649/649), 完成.
使用 8 个线程进行压缩
压缩对象中: 100% (254/254), 完成.
写入对象中: 100% (649/649), 40.96 MiB | 1.37 MiB/s, 完成.
总共 649 (差异 381),复用 649 (差异 381)
remote: Resolving deltas: 100% (381/381), done.
remote: GitLab: 500 Internal Server Error
To http://gitlab.local/python/myproject.git
! [remote rejected] master -> master (shallow update not allowed)
error: 推送一些引用到 'http://gitlab.local/python/myproject.git' 失败
使用git push --mirror
, 也是没有效果:
itaken@itaken-home:~/path/to/project$ git push --mirror http://gitlab.local/python/myproject.git
枚举对象: 649, 完成.
对象计数中: 100% (649/649), 完成.
使用 8 个线程进行压缩
压缩对象中: 100% (254/254), 完成.
写入对象中: 100% (649/649), 40.96 MiB | 1.79 MiB/s, 完成.
总共 649 (差异 381),复用 649 (差异 381)
remote: Resolving deltas: 100% (381/381), done.
remote: GitLab: 500 Internal Server Error
To http://gitlab.local/python/myproject.git
! [remote rejected] master -> master (shallow update not allowed)
! [remote rejected] origin/HEAD -> origin/HEAD (shallow update not allowed)
! [remote rejected] origin/master -> origin/master (shallow update not allowed)
! [remote rejected] 0.6.5 -> 0.6.0 (shallow update not allowed)
error: 推送一些引用到 'http://gitlab.local/python/myproject.git' 失败
配置添加shallowUpdate
也是失效的, git config --local --add receive.shallowUpdate true
:
itaken@itaken-home:~/path/to/project$ git config --local --add receive.shallowUpdate true
itaken@itaken-home:~/path/to/project$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = http://gitlab.local/python/myproject.git
fetch = +refs/heads/master:refs/remotes/origin/master
[branch "master"]
remote = origin
merge = refs/heads/master
[receive]
shallowUpdate = true
itaken@itaken-home:~/path/to/project$ git push -f
枚举对象: 649, 完成.
对象计数中: 100% (649/649), 完成.
使用 8 个线程进行压缩
压缩对象中: 100% (254/254), 完成.
写入对象中: 100% (649/649), 40.96 MiB | 870.00 KiB/s, 完成.
总共 649 (差异 381),复用 649 (差异 381)
remote: Resolving deltas: 100% (381/381), done.
remote: GitLab: 500 Internal Server Error
To http://gitlab.local/python/myproject.git
! [remote rejected] master -> master (shallow update not allowed)
error: 推送一些引用到 'http://gitlab.local/python/myproject.git' 失败
解决方案
使用git filter-branch -- --all
,去掉克隆的提交的 grafted 标记,完成处理!
itaken@itaken-home:~/path/to/project$ git filter-branch -- --all
Rewrite 51058cfd4fc213abf46ab4332bb52a9a05ca80xx (57/104) (1 seconds passed, remaining 0 predicted)
Ref 'refs/heads/master' was rewritten
Ref 'refs/remotes/origin/master' was rewritten
WARNING: Ref 'refs/remotes/origin/master' is unchanged
Ref 'refs/tags/0.6.0' was rewritten
itaken@itaken-home:~/path/to/project$ git push -u origin master
枚举对象: 649, 完成.
对象计数中: 100% (649/649), 完成.
使用 8 个线程进行压缩
压缩对象中: 100% (254/254), 完成.
写入对象中: 100% (649/649), 40.95 MiB | 677.00 KiB/s, 完成.
总共 649 (差异 381),复用 545 (差异 381)
remote: Resolving deltas: 100% (381/381), done.
To http://gitlab.local/python/myproject.git
* [new branch] master -> master
分支 'master' 设置为跟踪来自 'origin' 的远程分支 'master'。