Cha*_*ker 5 git git-submodules
我正在使用的项目之一在 it/s .gitmodules 文件中:
\n(iit_synthesis) brando9~/proverbot9001 $ cat .gitmodules | grep \'metalib\'\n[submodule "deps/metalib"]\n path = deps/metalib\n url = git@github.com:plclub/metalib.git\nRun Code Online (Sandbox Code Playgroud)\n\n[submodule "coq-projects/metalib"]\n path = coq-projects/metalib\n url = git@github.com:plclub/metalib.git\nRun Code Online (Sandbox Code Playgroud)\n当我通过命令行执行此操作时,由于 gitignore 文件,它不允许我这样做:
\n(iit_synthesis) brandomiranda~/proverbot9001 \xe2\x9d\xaf git submodule add --name coq-projects/metalib https://git@github.com:plclub/metalib.git coq-projects/metalib\n\nThe following paths are ignored by one of your .gitignore files:\ncoq-projects\ncoq-projects/metalib\nhint: Use -f if you really want to add them.\nhint: Turn this message off by running\nhint: "git config advice.addIgnoredFile false"\nRun Code Online (Sandbox Code Playgroud)\n我打算手动修改它,但感觉很脏,很奇怪。然后我将强制它更新:
\ngit submodule update && git submodule init # todo modify to only target metalib\nRun Code Online (Sandbox Code Playgroud)\n使用 git 命令从 stratch 重新添加并更新特定 git 模块的正确方法是什么?
\n正确的解决方案是:
\ngit submodule add -f --name coq-projects/metalib https://github.com/plclub/metalib.git coq-projects/metalib\nRun Code Online (Sandbox Code Playgroud)\n感觉很老套吗?它总是有效吗?
\n赏金:理想的解决方案,# - 在执行标准 git 子模块“pulls/inits”之前明确拉动 metalib 第一个(现在希望稍后修复,以便 git“pull” 完成这一切)
\n#-- Pull metalib explicitly 1st before doing the standard git submodule "pulls/inits" (for now hope to fix later so git "pull" does it all)\n# - I think this pulls the coq projects properly in proverbot\n# todo: Q: metalib missing, how do I pull it with original git submodule commands?\n# todo: /sf/ask/5233010821/\n# todo: https://github.com/UCSD-PL/proverbot9001/issues/59\n# todo: https://github.com/UCSD-PL/proverbot9001/issues/60\n# ### rm -rf coq-projects/metalib # why?\ngit submodule add -f --name coq-projects/metalib https://github.com/plclub/metalib.git coq-projects/metalib\nRun Code Online (Sandbox Code Playgroud)\n例如:
\ngit submodule update && git submodule init\nRun Code Online (Sandbox Code Playgroud)\n我希望给出的答案能够提供更多详细信息,通过提供我可以执行的检查来检查更新的 gitmodules 在 .gitmodules 文件、下载的存储库或任何检查中是否符合预期。代码和自然语言解释最适合验证。
\n相关说明,当我应该运行git submodule updatevs git submodule initvs vs 时,这真的让我很困惑。我通常git submodule init那么做git submodule update --init --remote。这是正确的还是不同的顺序更好?相关:哪个应该首先运行 git submodule update 或 git submodule init?
有关的:
\n\n小智 1
重新添加 Git 子模块的正确方法是使用以下命令:
git submodule add -f --name <new_submodule_name> <submodule_repository_URL> <submodule_path>
Run Code Online (Sandbox Code Playgroud)
在您的情况下,该命令将如下所示:
git submodule add -f --name coq-projects/metalib https://github.com/plclub/metalib.git coq-projects/metalib
Run Code Online (Sandbox Code Playgroud)
-f 标志用于强制添加子模块,即使它被 .gitignore 文件忽略。
要在添加子模块后更新子模块,可以运行以下命令:
git submodule update --init coq-projects/metalib
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
401 次 |
| 最近记录: |