繁体   English   中英

调整WordPress网站git储存库位置

[英]Adjusting WordPress site git repository location

我有一个包含WordPress网站的git存储库,其根文件夹如下所示:

/wp-admin
/wp-content
/wp-includes
index.php
license.txt
readme.html
wp-activate.php
wp-blog-header.php
wp-comments-post.php
wp-config-sample.php
wp-cron.php
wp-links-opml.php
wp-load.php
wp-login.php
wp-mail.php
wp-settings.php
wp-signup.php
wp-trackback.php
xmlrpc.php

但是,位于/wp-content/themes/<theme-name>/中的/wp-content/themes/<theme-name>/文件夹是我需要在此git存储库中控制版本的唯一文件夹。 我希望此存储库的根文件夹改为仅显示此主题文件夹的内容。

然而:

  • 我不想丢失任何提交历史记录
  • 我想保持文件原样,只是更改git存储库的位置

由于git不跟踪文件,也不跟踪内容,因此您可以节省移动内容的麻烦:

git rm *php license.txt readme.html /wp-admin /wp-includes -r
git mv /wp-content/themes/<theme-name>/* .
git rm /wp-content/ -r
git commit

这就是全部。 您会看到您的历史仍然存在,但现在您的根源已经成为主题。

git的好处是您的存储库是独立的。 因此,如果您想先尝试一下,而又不至于破坏git-skills之外的内容,则只需cp /path/to/project/root /backup/project并在/backup/project玩。 显然,您应该注意不要从那里推送更改。 另一种更git-full的方式是创建一个分支并在该分支中玩耍,但是我的经验是,对Git不太熟悉的人用一种更困难的方式来管理它,然后是一个“沙盒副本”。

您提到,除了git部分,您还想将其余结构保留在原处。 要做到这一点:

进行备份(在项目内部,然后再进行其他操作):

git archive HEAD > /tmp/my_project.tar

现在,如上所述运行git的东西,即使git-repo只包含您的主题。

然后,提取存档并将您的仅主题回购放在其中:

cd ..
mv <project-name>/ <theme_name>/ #your repo is now in a folder after the name of the theme
mkdir <project-name>/
tar -xf /tmp/my_project.tar <project-name>/ #extract the backup in the project-name folder.
rm -rf <project-name>/wp-content/themes/<theme-name>/ #remove the old theme
mv <theme-name>/ <project-name>/wp-content/themes/ # and move the git-repo with the theme in place of the old theme.

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM