You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

从Bitbucket迁移GitHub遇Git nullSha1问题求解决方案

解决Git迁移时"nullSha1: contains entries pointing to null sha1 for submodule"报错的方案

1. 定位问题子模块

先在本地克隆问题仓库,执行以下命令排查所有子模块状态:

git submodule status --recursive

输出结果中带有null或-前缀的条目,就是指向空SHA1的问题子模块。

2. 修复子模块引用

场景1:子模块已废弃

直接移除无效子模块:

git submodule deinit -f -- path/to/submodule
git rm -f path/to/submodule
rm -rf .git/modules/path/to/submodule

提交修改:

git commit -m "Remove invalid submodule with null SHA1"

场景2:子模块需保留

先检查.gitmodules和.git/config中的子模块配置,确认远程地址有效性,再执行同步更新:

git submodule sync --recursive
git submodule update --init --recursive --force

若仍无效,手动修改.gitmodules里的子模块url为有效远程仓库地址,重新执行上述同步命令。

3. 清理Git无效对象

如果问题仍存在,清理Git数据库中的冗余无效引用:

git gc --prune=now
git fsck --full

确认git fsck无无效SHA1提示后,重新提交修改。

4. 重新执行迁移

修复完成后,推送本地仓库到GitHub目标地址:

git remote add github https://github.com/your-username/your-repo.git
git push github --all
git push github --tags

内容的提问来源于stack exchange,提问作者Nagendra S.P

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.12 18:52:01