- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我的本地机器上有几个项目。创建了一个 super 项目并将不同文件夹中的项目添加为子模块。所有子模块文件都复制到 super 项目中。文件 .gitmodules 包含本地 url。如果我尝试推送 super 项目,我看不到我的子模块的文件。
我如何在 github 上推送带有子模块文件的 super 项目(而不是提交)?
附言我想单独处理项目并将它们作为一个 repo 发布。谢谢解答!
最佳答案
How I can to push superproject with submodules files (instead commits) on github?
您需要将子模块提交为文件夹,而不是子模块,因此您将丢失对其存储库的所有引用。
子模块只是存储库的提交。克隆 repo 时,git 将尝试根据 .gitmodules
中的 url 获取子模块 - 子模块的内容不包含在克隆操作中。在 GitHub 上,子模块仅显示为提交 - 它不包含任何内容。
要保留子模块的内容但不再是子模块,请按照 this answer 中的这些步骤操作.我从那个答案中获取了代码,而不是仅仅链接到它,因为它更长,而这就是您所需要的:
git rm --cached submodule_path # delete reference to submodule HEAD (no trailing slash)
git rm .gitmodules # if you have more than one submodules,
# you need to edit this file instead of deleting!
rm -rf submodule_path/.git # make sure you have backup!!
git add submodule_path # will add files instead of commit reference
git commit -m "remove submodule"
P.S. I would like to work separately with projects and publish them as one repo. Thanks for answers!
如果子模块的存储库位于 GitHub 上,GitHub 将有助于链接子模块,即您可以单击名称或提交以转到 GitHub 上该存储库的页面。
关于git - 如何在github上上传本地子模块的文件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20929094/
我是一名优秀的程序员,十分优秀!