这是我的.gitmodules:
[submodule "app/code/EthanYehuda/CronjobManager"]
path = app/code/EthanYehuda/CronjobManager
url = https://company@bitbucket.org/some_user/ethanyehuda_cronjobmanager.git
我确实删除并重新创建了子模块app/code/EthanYehuda/CronjobManager,因为我必须更改 URL。我的仓库的 git 历史与新仓库的历史完全不同。在这个问题的底部可以找到更多信息为什么它们不同。
所以我删除了子模块并再次创建它。
删除:
git submodule deinit app/code/EthanYehuda/CronjobManager
git rm app/code/EthanYehuda/CronjobManager
rm -rf .git/modules/app/code/EthanYehuda/CronjobManager
git commit -m "Deleted submodule app/code/EthanYehuda/CronjobManager"
重新添加:
git submodule add --force https://github.com/Ethan3600/magento2-CronjobManager.git app/code/EthanYehuda/CronjobManager
git commit -m "Add submodul app/code/EthanYehuda/CronjobManager"
现在,如果我去app/code/EthanYehuda/CronjobManager并执行,git remote -v我会得到:
origin https://github.com/Ethan3600/magento2-CronjobManager.git (fetch)
origin https://github.com/Ethan3600/magento2-CronjobManager.git (push)
到目前为止看起来不错...但是如果我切换到克隆(暂存)并拉动更改,那么我会得到:
Fetching submodule app/code/EthanYehuda/CronjobManager
error: The server refused requests to not specified object 9b677ef0e750acb9292030306bd97a3ee2734c61
为什么 git 历史记录不同:
我收到了一个 Zip 文件的项目。所以我创建了一个新的 repo 并提交了文件并将其推送到我的 bitbucket。
然后我发现,这是一个公共的 github 项目。所以我想将 URL 更改为 github 存储库。但是因为他们有完全不同的 git 历史(我的仓库只有一个初始提交,而 github 仓库包含所有提交。)
因此,仅更改 URL 是行不通的。