When I work on custom WordPress builds, it tends to be a collection of a theme, one or more custom plugins, and a series of third party plugins. For this reason, I usually opt to track the entire wp-content
directory in a single Git repository.
Sometimes it makes sense to track third party plugins but often, I prefer not to and in some cases, I’ve even changed my mind and had to remove tracking. Here’s how I go about it.
First up, we need to ignore anything within the /plugins
directory but allow continued tracking of any plugins that have a particular prefix. Add this to the .gitignore
file. This combination of rules ensures that any plugins I create prefixed with hookturn-
will continue to track in the repo. Use a prefix appropriate to your project.
Next, we use a command to remove all the files from Git. This removes all files from the /plugins
directory. Note that this doesn’t delete the files from the project – only from the Git repo.
Now we just need to commit the changes. This commit will have the changes to the .gitignore
file as well as the files from plugins we still want to track.