Adjusting WordPress site git repository location -
i have git repository containing wordpress site, root folder looks so:
/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
however, theme folder located in /wp-content/themes/<theme-name>/
folder need version controlled within git repository. i'd root folder of repository instead show contents of theme folder only.
however:
- i don't want loose commit history
- i want keep files are, , change location of git repository
since git
not track files, content, save move stuff around:
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
this all. you'll see history remains, yet root theme.
the nice thing git, repository self-contained. so, if want try first, without risk of breaking beyond git-skills, can cp /path/to/project/root /backup/project
, play around in /backup/project
. should careful not push changes there. another, more git-full way create branch , play around in branch, experience is, people less familiar git, have harder way of managing this, "sandbox-copy".
besides git
part, mention, want keep rest of structure in place. that:
make backup (inside project, before else):
git archive head > /tmp/my_project.tar
now run git stuff mentioned above, i.e. making git-repo contain theme.
then, extract archive , place theme-only repo in there:
cd .. mv <project-name>/ <theme_name>/ #your repo in folder after name of theme mkdir <project-name>/ tar -xf /tmp/my_project.tar <project-name>/ #extract backup in project-name folder. rm -rf <project-name>/wp-content/themes/<theme-name>/ #remove old theme mv <theme-name>/ <project-name>/wp-content/themes/ # , move git-repo theme in place of old theme.
Comments
Post a Comment