Git - Track a folder from a separate repository and have a separate repository set up inside of it - wordpress

I have the following folder structure running on an NGINX server.
-- Laravel installation
-- Magento installation [DOCUMENT ROOT]
-- Laravel's public folder renamed to a different name
-- WordPress installation
The website structure goes something like:
www.example.com = Magento
www.example.com/subsite = Laravel [This is its 'public' folder.
Rest of the folders are placed in a separate folder]
www.example.com/subsite/blogsite = WordPress [Running inside of Laravel]
I had to do the Laravel folder separation because I wanted to make it work as a subdirectory but somehow couldn't figure out how to do it. So I instead followed the Method #1 in this post.
The challenge now is to manage these 3 repositories separately.
I have two major concerns:
How do I track the stranded Laravel public folder which is now inside the Magento repository?
How can I manage the WordPress installation as another separate repository?

1. How do I track the stranded Laravel public folder which is now inside the Magento repository?
As per this answer, you can add external directories to your working tree with this git command:
git --work-tree=/ add /home/some/directory
2. How can I manage the WordPress installation as another separate repository?
You can use .gitignore to ignore the subfolder in the Magento subfolder.
In the Magento root, create a file named .gitignore
In this file, create a list of folders/files you want to ignore, in your case you want to ignore the Wordpress folder within the Laravel directory (assuming it's under public/wordpress.
/public/wordpress/
/public/wordpress/*
Do a git commit: git commit -am 'Ignore the Wordpress folder'
Now you can just create a seperate git tracking instance on the Wordpress folder.

Related

AWS Lightsail Wordpress Version control

I'm working on a wordpress site hosted on an AWS Lightsail instance (Bitnami) and i'd like to have version control to work on our site themes with a coworker.
I like the idea of just having to git pull to make changes to the site.
In the wordpress folder (that contains wp-admin, licences, wp-config.php, etc...), there is the wp-content folder but it's a symbolic link that points outside the wordpress folder to root/bitnami/wordpress/wp-content. I can't use git in the wordpress folder but I can set it up in the root/bitnami/wordpress/wp-content but it feels like bad practice since it asks me for admin privileges for every command line.
Is there a reason the wp-content folder is a symbolic link that points to outside the wordpress folder or is it just a mistake from the person who set things up?
Is it okay to use git to bypass an ftp client in this case?
So I just had this same issue today, and I resolved this by moving the directories for .../wp-content to the location of the symlinks and deleting the symlinks.
This was my process (though you could delete the symlinks first):
Move wp-content mv /bitnami/wordpress/wp-content /location/of/wordpress/temporary-directory-name
Delete symlinks rm -f /location/of/wordpress/
Rename temporary-directory-name using move mv /location/of/wordpress/temporary-directory-name /location/of/wordpress/wp-content
You can then repeat the same steps for the wp-config.php file. Once this was done I was able to verify Wordpress was still working on my LightSail instance. Hope this helps

Add a folder from outside the repository to repo?

I'm working on a WordPress theme, and I've just created a repository from the theme folder inside /wp-content/themes/ directory. But now I've moved some code from the functions.php file to two plugins in the /wp-content/plugins/ directory.
Question, can I add the plugins folder to my exiting repository?
You can store them directly in your repo and create symlinks to them in /wp-content/plugins. This is a popular method, many people use it to manage their dotfiles with git.

where to put wordpress htaccess on openshift

I have cloned my wordpress application from openshift with git, in my cloned application there is php folder, when i put my htaccess file in it then i commit my changes like this :
git add -A
git commit -m 'ok'
git push
My htaccess file is not pushed in the application repository folder on openshift, but when i put it via ftp with filezilla it works, not with git.
I don't know where i have to put .htaccess file ? if it is in php folder, why it's not uploaded ?
If you used our official quickstart, you would need to use an action_hook (probably deploy) to copy a .htaccess file into place, otherwise the files are actually not stored in a place that is affected by git. You could also try using this quickstart( https://github.com/openshift-quickstart/openshift-wordpress-developer-quickstart) where EVERYTHING except for uploads, is stored in git (plugins, themes, etc)

How to clone WordPress theme from github

I've been developing a wordpress theme on a dev site, and all along I've been pushing it to github. It's now ready to be deployed to my live site, but I'm not sure how to do that.
What I've tried so far (that didn't work) is creating an empty /wp-content/themes/my-theme/ directory on my live site, and I cd into it. Then I use git clone git#github.com:path/to/my-theme.git but that creates another directory inside of my my-theme/ directory with all of the theme files inside of it. To clarify, that now creates:
/wp-content/themes/my-theme/my-theme/[all theme files here]
But I just want the files from the github repo to be placed directly into the original empty my-theme directory that I created.
try git clone <repo> . -- you can specify the directory as the last argument.

Keeping WordPress in version control - separate repo for theme

I have my WordPress project under Git and have WordPress as a submodule. I want to keep my theme development in a separate submodule, but within the current setup and am having some difficulties getting the theme setup as a submodule.
Here is my file system:
/.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...)
Now when I push my master repo to github, and try and clone it on another machine, the wordpress submodule downloads fine, but my theme folder does not, and I get an error about submodule not being defined.
I've tried using this to add my theme as a sub-module:
git submodule add ./wp-content/themes/test-theme/.git ./wp-content/themes/test-theme
but I get the following error: "remote (origin) does not have a url defined in .git/config"
How do I defined my theme repo as a submodule, when it is essentially hosted "inside" the project and not at a separate repository online?
Thanks.
I'm still relatively new to using submodules but I have been trying to do something similar and found two blog posts quite helpful: one by Clint Berry and another by David Winter.
The principle of a submodule is that it should have a separate repo and then when you add that submodule to a new project the add submodule command should be pointing to the repo:
git submodule add https://github.com/youruseraccount/test-theme.git ./wp-content/themes/test-theme
git init
git update
I believe this is why you are getting the error, there is no URL associated with the origin. Look in the files .gitmodule and .git/config to confirm. If I am correct, the git init will add the necessary entries in .git/config and git update this will pull the theme from the repo and put it into the subdirectory.
See here for how to commit changes to the submodule and here for how to remove the submodule.

Resources