我正在使用的项目之一在 it/s .gitmodules 文件中:
(iit_synthesis) brando9~/proverbot9001 $ cat .gitmodules | grep 'metalib'
[submodule "deps/metalib"]
path = deps/metalib
url = [email protected] /cdn-cgi/l/email-protection:plclub/metalib.git
但我很确定应该是 https://github.com/UCSD-PL/proverbot9001/issues/59:
[submodule "coq-projects/metalib"]
path = coq-projects/metalib
url = [email protected] /cdn-cgi/l/email-protection:plclub/metalib.git
当我通过命令行执行此操作时,由于 gitignore 文件,它不允许我这样做:
(iit_synthesis) brandomiranda~/proverbot9001 ❯ git submodule add --name coq-projects/metalib https://[email protected] /cdn-cgi/l/email-protection:plclub/metalib.git coq-projects/metalib
The following paths are ignored by one of your .gitignore files:
coq-projects
coq-projects/metalib
hint: Use -f if you really want to add them.
hint: Turn this message off by running
hint: "git config advice.addIgnoredFile false"
我打算手动修改它,但感觉很脏,很奇怪。然后我将强制它更新:
git submodule update && git submodule init # todo modify to only target metalib
使用 git 命令从头开始重新添加并更新特定 git 模块的正确方法是什么?
正确的解决方案是:
git submodule add -f --name coq-projects/metalib https://github.com/plclub/metalib.git coq-projects/metalib
感觉很老套?它总是有效吗?
赏金:理想的解决方案,# - 在执行标准 git 子模块“pulls/inits”之前明确拉动 metalib 第一个(现在希望稍后修复,以便 git“pull” 完成这一切)
#-- Pull metalib explicitly 1st before doing the standard git submodule "pulls/inits" (for now hope to fix later so git "pull" does it all)
# - I think this pulls the coq projects properly in proverbot
# todo: Q: metalib missing, how do I pull it with original git submodule commands?
# todo: https://stackoverflow.com/questions/74757297/how-do-i-make-sure-to-re-add-a-submodule-correctly-with-a-git-command-without-ma
# todo: https://github.com/UCSD-PL/proverbot9001/issues/59
# todo: https://github.com/UCSD-PL/proverbot9001/issues/60
# ### rm -rf coq-projects/metalib # why?
git submodule add -f --name coq-projects/metalib https://github.com/plclub/metalib.git coq-projects/metalib
例如和:
git submodule update && git submodule init
Bounty2:需要答案中的详细信息才能验证建议是否确实有效
我希望给出的答案能够提供更多详细信息,通过提供我可以执行的检查来检查更新的 gitmodules 在 .gitmodules 文件、下载的存储库或任何检查中是否符合预期。代码和自然语言解释最适合验证。
哪个先初始化还是先更新?
相关说明,我什么时候应该跑步git submodule update
vs git submodule init
vs 真的让我很困惑。我通常这样做git submodule init
then git submodule update --init --remote
。这是正确的还是不同的顺序更好?有关的:哪个应该首先运行 git submodule update 或 git submodule init ? https://stackoverflow.com/questions/75342383/which-should-be-ran-first-git-submodule-update-or-git-submodule-init
related:
- https://github.com/UCSD-PL/proverbot9001/issues/59 https://github.com/UCSD-PL/proverbot9001/issues/59
- https://github.com/UCSD-PL/proverbot9001/issues/60 https://github.com/UCSD-PL/proverbot9001/issues/60