Git 骚操作,如何推送浅克隆过的本地仓库到新的远程地址
有些优秀的项目,前一天还在用,后面发现瞬间就没了,因为违反了 DMCA 法案,比如 https://github.com/github/dmca/blob/master/2019/12/2019-12-13-premiumsoft.md。
先前克隆到本地时选择了单分支浅克隆,想新开一个远程仓库推送过去,发现悲剧(被拒)了。
To new remote repo address
! [remote rejected] branch -> branch (shallow update not allowed)
error: failed to push some refs to 'new repo addr'
原始的远程仓库已经无法访问了,所以 fetch --unshallow
是不可能的。
在 Stack Overflow 找到了解决方案,Remote rejected (shallow update not allowed) after changing Git remote URL,虽不是被采纳答案,却也是有效的。此方案最主要的操作在于 git commit --amend
(amend this commit with an interactive rebase),使用 --amend
重写提交记录。
References
- https://www.dmca.com/faq/What-is-a-DMCA-Takedow.
- https://stackoverflow.com/a/52106392.