今天 push 代码的时候遇到一个问题:
1 2 3 4 5 6 7 8 9
| Counting objects: 47, done. Delta compression using up to 4 threads. Compressing objects: 100% (44/44), done. Writing objects: 100% (47/47), 573.15 KiB | 0 bytes/s, done. Total 47 (delta 11), reused 0 (delta 0) remote: Resolving deltas: 100% (11/11), done. To github.com:SunDoge/xxxx.git ! [remote rejected] master -> master (shallow update not allowed) error: failed to push some refs to 'git@github.com:SunDoge/xxxx.git'
|
找到 stackoverflow 上的一个答案
https://stackoverflow.com/questions/28983842/remote-rejected-shallow-update-not-allowed-after-changing-git-remote-url
那么问题也就很明显了,我在 clone 原仓库时用了 git clone --depth 1
,导致本地为 shallow repo。解决方法也很简单
1
| git fetch --unshallow origin
|
origin
就是原仓库。fetch 完就能正常 push 了。