git 添加submodule 以及更名

缘由

使用Hugo可以创建类似博客的网站,用md编辑文章后,hugo可以用网页展示出来。 另外需要添加第三方themes, 而第三方themes是也是一个项目
所以需要在本项目里添加子模块, 添加submodule很简单,但是需要原来的module名字叫hugo-themes, 而hugo在生成网页的时候,只认themes目录

创建hugo项目

hugo new site demo

执行后会在demo目录创建如下结构,为了添加自己的themes, 先将themes目录删除

ls 
archetypes  config.toml  content  docker_compose static  themes

添加git后,再添加hugo-themes子模块

git submodule add https://gitlab.xxxx.com/xxxx/hugo-themes.git

然后目录就多了hugo-themes目录,作为submodule 存在

更名并同步

git mv hugo-themes themes

git submodule sync

git add -u
git commit
git push 

即可完成submodule 更名

原文地址:https://www.cnblogs.com/hustcpp/p/13092625.html