|# .gitignore for WordPress|
|# Bare Minimum Git|
|# ver 20150227|
|# This file is tailored for a WordPress project|
|# using the default directory structure|
|# This file specifies intentionally untracked files to ignore|
|# The purpose of gitignore files is to ensure that certain files not|
|# tracked by Git remain untracked.|
|# To ignore uncommitted changes in a file that is already tracked,|
|# use `git update-index --assume-unchanged`.|
|# To stop tracking a file that is currently tracked,|
|# use `git rm --cached`|
|# Change Log:|
|# 20150227 Ignore hello.php plugin. props @damienfa|
|# 20150227 Change theme ignore to wildcard twenty*. props @Z33|
|# 20140606 Add .editorconfig as a tracked file|
|# 20140404 Ignore database, compiled, and packaged files|
|# 20140404 Header Information Updated|
|# 20140402 Initially Published|
|# ignore everything in the root except the "wp-content" directory.|
|# ignore all files starting with .|
|# track this file .gitignore (i.e. do NOT ignore it)|
|# track .editorconfig file (i.e. do NOT ignore it)|
|# track readme.md in the root (i.e. do NOT ignore it)|
|# ignore all files that start with ~|
|# ignore OS generated files|
|# ignore Editor files|
|# ignore log files and databases|
|# ignore compiled files|
|# ignore packaged files|
|# ignore everything in the "wp-content" directory, except:|
|# "mu-plugins" directory|
|# "plugins" directory|
|# "themes" directory|
|# ignore these plugins|
|# ignore specific themes|
|# ignore node/grunt dependency directories|
I'm thinking these should be ignored as well:
for example, when I pulled a repo and then rsync'd a fresh empty wp install over it, it's now asking for a commit just because my fresh files didn't have "?>" at the ends of the files.
Here is quick update for those who are on OSX and/or using IntelliJ
I like the idea of ignoring the plugins in order to conserve repo size. I'd think ideally, all plugins (custom or third party) should be contained as an object in a discrete repo. Utilities like Composer or even a good old Readme file should allow one to find and install the required plugins to run the WP site/app.
@chrisgeary92 Thanks for your input, I go back and forth on this idea. For 99% of the project on which I work, we update the plugins from within WordPress. When doing development, I pull the repo, run composer, and then update the plugin if necessary. For the other 1% of projects, I do add
@junibrosas I would say it depends on what you're building. When I'm doing a site for client, which is what I'm doing most of the time, I create the repo from the root of the website. If I'm specifically just building a theme, not an entire site, then I create the repo for just the theme folder.
Some people prefer to have one project repo (for the entire project) and use a separate repo within the project repo for the theme. For me, I find this adds a lot of complexity and very little benefit, so I do not do this.
A good thought but this folder is already excluded due to
As a side note, I'm now using this other WordPress .gitignore file, which excludes everything by default, allowing me to whitelist only those plugins and/or themes I want to include.
Thanks for the note. If
If you're not seeing that behavior (or if you have a use-case for
Hello, I'm now using this gitignore for development. My question is on the plugins management:
It's very useful to have plugins tracked across environments and this gitignore tracks them unless you ignore specific plugins (like hello.php ecc..) which is fine. The problem is when the plugins have been updated. The files will sync because they are tracked in the GIT repo, which is ok. But what if the updated version of the plugin needs a DB update/upgrade, too? If so, you must always deactivate and activate again all the updated and pulled plugins to ensure eventual tables of the plugins are synced, too.
Do you have a solution for this problem or it is better to not track the plugins at all and install them manually on each environment which is a little bit frustrating to me?