2

我正在使用类似于 Mark Jaquith 的WordPress Skeleton的 WordPress 目录结构,它将 WordPress 与内容作为子模块放在一个单独的目录中:

/content
/wp
/local-config.php
/wp-config.php
/index.php

我还使用 git 和 post-receive 挂钩将我的代码更改推送到我的实时服务器。除了我尝试升级 WordPress 并将其推送到实时服务器之外,这一切都很好。

这就是我在本地机器和远程服务器上设置 repo 的方式:

本地机器

cd /www
git init .
git submodule add git://github.com/WordPress/WordPress.git wp
git commit -m "Add Wordpress submodule."
cd wp
git checkout 3.5

签出标签后,我从 git 收到关于处于“分离 HEAD”状态的警告。由于我不打算对 WordPress 做出任何承诺,我认为这不应该是一个问题。

cd ..
git commit -am "Checkout Wordpress 3.5"

远程服务器

git init --bare
cat > hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/home/public git checkout -f

chmod +x hooks/post-receive

git remote add web ssh://user@server/home/private/code/wordpress.git

git push web +master:refs/heads/master

我收到此错误:

No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to 'ssh://userserver/home/private/code/wordpress.git'

经过一番谷歌搜索,看起来我可以使用此命令将主分支同步到服务器(我不知道这是如何工作的)

git push web +master:refs/heads/master

但这对我没有帮助,因为我不想跟踪 master,我想跟踪发布标签 3.5。更多的谷歌搜索让我得到了这个命令:

git push web +3.5~0:refs/heads/master

要升级子模块,我这样做:

cd wp
git fetch && git fetch --tags
git checkout 3.5.1
git push web +3.5.1~0:refs/heads/master

我这样做正确吗?我看到的所有教程都git push web已经完成了。大多数甚至不包括升级子模块。这确实有效,但如果我不必使用这种奇怪的推送语法,我会觉得不舒服。

如何正确将此分离的 HEAD 状态推送到服务器?

我也尝试过使用分支,git checkout -b mywp 3.5但是当需要升级时,我不知道如何将新的 3.5.1 标签引入我的mywp分支。

在WP Answers上问过这个问题,但在这里可能更合适。

4

1 回答 1

3

在远程服务器上尝试:

git submodule update --init --recursive

这将递归更新您的所有子模块

您还可以发出:

git fetch --tags

这将更新您的本地标签,从中央远程仓库获取更新列表。

于 2013-01-30T20:16:54.053 回答