I am working on a local environment and I am pulling down a plugin that has its own git repository that is linked to the production server (also staging server). The only problem is that the plugin folder itself is in a folder like so:
repository-folder
real-plugin-folder
And my plugins directory looks like so:
plugins
plugin1
plugin2
plugin3
repository-folder
real-plugin-folder
plugin4
Is there a way to define a new path for this one particular plugin so that it will show up in my local environment and so I can edit it while keeping the plugin git repository structure in contact so I can push up to that repository? (some sort of path definition in wp-config.php?).
I think Git submodules might be the answer? But honestly I don't have time to tinker with it: https://git-scm.com/book/en/v2/Git-Tools-Submodules.
Why don't you just start your repo in "repository-folder" ? You don't need to follow the same parent folder in git.
I hope it helps you at least a clarification here
If you are on a Linux environment, setup a symlink for the plugin:
cd plugins
mkdir real-plugin-folder
ln -s respository-folder/real-plugin-folder/plugin.php real-plugin-folder/plugin.php
Related
In wordpress development, we have to deal with upgrade version of plugins and I don't know how to manage code repository with them. actually, we have 3 folders like wp-content, wp-admin, wp-includes, ...
Should I push all of the code which belong to wordpress folder into the GIT repository? Then the new version of plugin will affect to changes of files.
How do I manage the changing of files as less as it can? Should I use .gitignore for it?
Updated: I found the solution at here with the examples. Check this link out
.It is really cool
WordPress can be a joy for running in a GIT repository, this is how I handle it.
I gitignore wp-config.php because that is usually different between local, staging and live sites.
I also gitignore the uploads folder because binary files in git suck and your repo will grow brutally fast. Plus it makes it a pain in the butt to do local development while the site is live.
There are some cool solutions out there, search for Bedrock by Roots for doing interesting deploys, but honestly the simplest way is just to make a repo of the entire install minus the uploads and wp-config.php.
Manually create the wp-config.php on the server.
Use rsync to manage the uploads or you could use FTP if you're not keen on the terminal.
This is the .gitignore file that I use for my projects.
/.idea/
*.log
/wp-includes/
/wp-admin/
/wp-content/advanced-cache.php
/wp-content/backup-db/
/wp-content/backups/
/wp-content/cache/
/wp-content/languages/
/wp-content/plugins/
/wp-content/upgrade/
/wp-content/uploads/
/wp-content/wflogs/
/wp-content/wp-cache-config.php
/.htaccess
/license.txt
/readme.html
I only work with private repositories so I don't have to exclude the wp-config.php.
I am working on a Wordpress site, and been given access to the git repository for this project. The entire WP install is in the Repo. All I care about is being able to push my changes to the theme and a select list of plugin folders, ie:
/wp-content/themes/myTheme2017/
/wp-content/plugins/myPlugin1/
/wp-content/plugins/myPlugin2/
....
How can I exclude everything else from being tracked? How can I update my local WP install, and customize my wp-config.php file, and not have those changes be tracked?
As per How do I configure git to ignore some files locally?, I can specify the files I want excluded much like in gitignore files. Then, I can run git update-index --skip-worktree [<file>...] and get my desired results.
git update-index --skip-worktree wp-config.php
The real question is then can I exclude entire folders? Do I have to run the skip-worktree command on every file?
The real question is then can I exclude entire folders? Do I have to run the skip-worktree command on every file?
Yes, every file: Git does work with content (files), not containers (directories).
You can find here an approach using submodules
git submodule add -f https://github.com/wp-plugins/wp-migrate-db.git ./wp-content/plugins/wp-migrate-db
git commit -m "Added WP Migrate DB plugin"
That allows to commit separately in your parent repo or your submodule.
I've been making a Wordpress theme and using git to save progress. My whole Wordpress site is in the git project, and I would like to remove everything except the theme folder so I can easily transplant it on other Wordpress sites.
I know one way is to just delete everything and move the theme to the root folder and commit. But checking out after that will be more complicated, right? So is there another way?
Thanks.
If you are interested in keeping the full history of your Theme folder, you can use git filter-branch and remove everything else.
See "Extract part of a git repository?" ,to be done in a clone of your current repo:
git filter-branch --subdirectory-filter Project/SubProject-0 --prune-empty -- --all
I am working on webpage, and I need version tracking, so I'm uploading it to github.
Here is the underlying set up.
https://developers.google.com/appengine/articles/wordpress
Now that I have the base CMS ready to go, I need to get the base code uploaded before I start making changes.
lloydm#lloydm-E6320:~/Downloads/rtt/rtt-code$ pwd
/home/lloydm/Downloads/rtt/rtt-code
lloydm#lloydm-E6320:~/Downloads/rtt/rtt-code$ git status
# On branch master
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# wordpress/
nothing added to commit but untracked files present (use "git add" to track)
lloydm#lloydm-E6320:~/Downloads/rtt/rtt-code$ ls
app.yaml cron.yaml php.ini wordpress
lloydm#lloydm-E6320:~/Downloads/rtt/rtt-code$ git add .
fatal: Not a git repository: wordpress/wp-content/plugins/../.git/modules/appengine-wordpress-plugin
I've never used github before, so I was just following the github website stuff. I have zero idea what this error means or how to prevent it. I can't find anything that I think is related to it.
You need to set up your git repo correctly.
I think you followed this section "Installing WordPress on your development environment" from the link you provided https://developers.google.com/appengine/articles/wordpress
So what you did was download WordPress into your folder which you set up to be a .git repository. However, the WordPress project builder you downloaded itself contains a .git repository.
Check if you have a /workpress/.git file. It likely contains something like :
gitdir: ../.git/modules/wordpress
If you do, then that explains the error I think.
As for setting it up correctly, there are many tutorials available.
One way is to use Git for theme deployment, rather than having it manage your entire WordPress installation --> http://culttt.com/2013/04/08/how-to-deploy-wordpress-themes-with-git/
Another way is to add wordpress as a submodule http://www.efeqdev.com/website-development/this-is-how-we-version-control-and-deploy-our-wordpress-websites-with-git/
or Just make a ~/Downloads/rtt/rtt-code/wordpress/myWebpage directory and set up a git repo in it. http://www.whistlenet.com/git-for-wordpress/
I think you just need to go into the wordpress folder and then run the git status command. As the directory(rtt-code) is not a git directory but contains within it the git repo, that is wordpress, you are getting this error.
Inside the wordpress folder, all your git commands would work perfectly well...
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.