保持WordPress版本控制 - 单独的主题回购

low*_*_22 3 git wordpress

我在Git下有我的WordPress项目,并将WordPress作为子模块.我想将我的主题开发保存在一个单独的子模块中,但是在当前设置中并且在将主题设置作为子模块时遇到一些困难.

这是我的文件系统:

/.git (master repo)
/index.php
/wp-config.php
/wordpress (WordPress repo as a submodule)
/wp-content 
  themes
     test-theme (theme repo)
        .git
        index.php
        (etc...)
Run Code Online (Sandbox Code Playgroud)

现在,当我将我的主仓库推送到github,并尝试在另一台机器上克隆它时,wordpress子模块下载正常,但我的主题文件夹没有,我得到一个关于未定义子模块的错误.

我尝试使用它将我的主题添加为子模块:

git submodule add ./wp-content/themes/test-theme/.git ./wp-content/themes/test-theme
Run Code Online (Sandbox Code Playgroud)

但是我收到以下错误:"remote(origin)没有在.git/config中定义的url"

如何将主题回购定义为子模块,当它基本上托管在项目"内部"而不是在线上的单独存储库中时?

谢谢.

nse*_*ord 5

我仍然相对较新使用子模块,但我一直在尝试做类似的事情,并发现两个博客文章非常有用:一个是Clint Berry,另一个是David Winter.

子模块的原理是它应该有一个单独的repo,然后当你将该子模块添加到一个新项目时,add submodule命令应该指向repo:

git submodule add https://github.com/youruseraccount/test-theme.git ./wp-content/themes/test-theme
git init
git update
Run Code Online (Sandbox Code Playgroud)

我相信这就是你收到错误的原因,没有与原点相关的URL.查看文件.gitmodule和.git/config以确认.如果我是正确的,git init将在.git/config和git update中添加必要的条目,这将从repo中提取主题并将其放入子目录中.

请参见这里了解如何更改提交到子模块和这里的如何删除子模块.