Update and fix WordPress gitignore #3295
Conversation
|
@pedrosanta thanks for the great writeup about the state of the template. I've skimmed the linked PRs and I get the consensus here that #2972 was too aggressive. Two options to help us get back to a good place with this template:
Happy to go with either option here, and I'll cc everyone who has been active in the linked PRs to get their feeling for the situation: @rohanvakharia @malithmcr @kolorafa @hdwebpros @chougron @samuraijane @NerdsvilleCEO @Triloworld @stkrzysiak If we're in agreement with using this PR as a baseline, then I'll close out the other open PRs and funnel them into this PR. |
|
In general, WordPress plugins and themes create files and directories in distributed places. For example, they do create cache files/directories in the In the WordPress ecosystem users create following things custom made:
We must allow only the above three directories with a selective approach. The reason for being selective is to exclude the pre-installed plugins and themes. Besides, we must exclude log files, DB backup files, cache directories, etc which people keep dangling the root directory and other places. I am not against the declarative approach, it is just that it will not work here because of the too many unknowns. |
Like I said on the PR and previous comments, I have a strong feeling that this (Perhaps such an approach might be something that fits better on the About the declarative approach not working, because of the many unknowns, I think my reasoning above effectively makes this a not-problem, because I don't think we should be striving to address all the unknowns in the first place, I don't think that's a sensible approach. This (Though if there's is a provenly hugely used cache plugin, or so, I admit we could ignore that folder, etc.) And, for the record, I do stress I think this |
|
Also, and the more I think of it, the more I feel there are two major approaches to this (related to my Q1 and Q3). I'm starting to get the sense that ignoring WP core and blanket allowing only all the If the above is the case, I think it probably makes more sense—an approach that a good number of people use too—to have a repository for each custom theme and custom plugin—and have the repos cloned inside WP file structure. So, I feel there might be two major approaches to this:
So, I'm not sure if we shouldn't model this |
|
I go for theme as starter, not solution to all problems. What scenario is common and proper to be in this template for EVERYONE?
99% just create plugins/themes so this is the case. 3rd-party must be case by case different.
More? You can customize. After all, is starter and need to be for:
More?
This fix any discussion in this field as files name distinguish scenario. |
|
In one line: |
|
@Triloworld great contribution, thanks. Will follow through with your suggestions (those two plugin/themes lines and comments) and update the PR. As for the multiple files that is certainly interesting. Perhaps we can keep a sensible default on root folder and add the other files to the |
|
Also @Triloworld didn't get your take regarding ignoring WP core or not, etc—see my comment on that. Based on that comment, what's your take about ignoring WP core or not? (If we went with multi-files approach perhaps default could have WP core committed/not-ignored and then you could add the Because, this list of things to ignore you make below, it's super on point, well-thought and consise, and you haven't enumerated WP core here, so I assume you're considering committing/not-ignoring WP core with this one, yes? I like this scope/list and I think we should follow it, as it complies with all the requisites of a 'starter sensible default' for WordPress.
|
|
Example What I think about core files:
My description what I ask myself about this file: My example: |
|
Hi @Triloworld just noticed these two suggestions you made were already built in:
Here: https://github.com/github/gitignore/pull/3295/files#diff-f2cf96854b528e9828c4ca34a4917e54R42
And here: https://github.com/github/gitignore/pull/3295/files#diff-f2cf96854b528e9828c4ca34a4917e54R48 Like so? So if I understand correctly the PR goes along your position/suggestions, yes? |
Yep. This is great but this will ignore all plugins/themes that wasn't great. By default Wordpress now recommend having one "twentytwenty" theme in dir. So this need to be revalidated
No commit. Give line by line list of files.
Declarative. Just to have starter, no "guessing"
Ignore proper one so now is better to have only one commented as a core one that will go untouched:
|
You're absolutely right—site health freaks out when there isn't a default one installed, yes. Should I add an exclude for
Or just add the
|
Hi @Triloworld , but now that I come think of it, even if Health Check gives a warning, since this is an example theme, aren't we overdoing it by commiting Wdyt? |
|
Any further thoughts/discussion on this? |
|
@shiftkey , how to best proceed with this? |
|
I really don't want to be 'that guy', but I think this repository (that depend a lot of popular tools, like for instance toptal/gitignore.io) should really have a working WordPress @shiftkey any thoughts? |
(Reasons for making this change:)
Background for this PR
#2972 seems to have broken the WordPress gitignore—using this file with a brand new install, allows to add pretty much all the install, because it's missing a catch-all rule, since it operates with excludes mostly. So WordPress gitignore wasn't seemingly working at all.
#3125 it's an update to add configuration file to gitignore, but it doesn't fix all the other underlying issues with this gitignore.
#3093 as noted by @NerdsvilleCEO here is missing a rule to allow for gitignore itself. (#3293, #3378, #3438 are duplicates.)
#3282, from which this PR is based, is IMHO the better attempt at fixing this gitignore, but I see two potential issues with it:
Ignores
*.sqlfiles, and I'm afraid we might be over assuming the ignores, as a typical WordPress install doesn't seem to generate*.sqlfiles, and I think it might be more linked to a specific workflow that generates*.sqlfiles (see here and here).Employs a 'catch-all' approach for all root files with exclude rules, and I think that might not be the safest or best approach—it might conflict and break other gitignore files you mix with this one, and force users to always exclude other non-WP related paths that otherwise they might want to include in the repository. IMHO, a declarative approach of all the paths and files one needs to ignore is the best way to go.
Proposal/discussion for a WordPress gitignore
This PR adds my proposal for a gitignore for WordPress alongside with a couple questions up for discussion.
But before those, I want to frame my approach.
Objectives of this gitignore
Since Git is mostly useful for tracking code, I feel that the uploads folder, usually full of images/binaries should be ignored.
One might have other folders with binaries on their project/workflows (caches, etc), but I consider these files to be starters/base files from which you can expand your own gitignores, so if there are more of these folders on
wp-contentyou should maintain them on your own gitignore.Q1 — Commit WP Core or not?
While for some this might be an obvious response, I'm still not convinced of either approach as a base, as I can see both being useful:
Committing core. Pros: to have a code-ready deploy of one site and, help lock WP version for a specific site. Cons: Committing plugins and WP core code can make repo out-of-sync when one instance is upgraded through Admin, additional repo size.
Keeping core out. Pros: smaller repo, WP updates don't need to be committed to have consistency. Cons: additional setup for dev workflow, deploys, etc. Also, if we keep WP core out shouldn't we also keep third-party plugins and/or parent-themes out of repo too? (Q3)
My proposal ignores WP core, but has a note for those that want to commit it, they can do so by deleting/commenting one section of the gitignore. But I'm still not convinced of which approach this gitignore should take. (Before #2972 the approach was committing core.)
Q2 — Catch-all or declarative approach?
Here, I think a declarative approach to be the best. Catch-all has a big risk of conflicting with other gitignore files of this repo if you mix several together, as I explained before/above.
Q3 — Should we allow all themes and plugins, or ignore all and whitelist our own?
The gist of this proposed gitignore and all the others mentioned before is to allow all the themes and plugins by default.
But this can lead to having 3rd party plugins and parent custom themes—that aren't our custom code and of similar nature of WP core code—being added and tracked. Shouldn't these also to be ignored if we go with having the WP core ignored? If so, wasn't better to ignore all themes and plugins, and have each one whitelist their own custom themes and plugins on their gitignore files (like Sal Ferrarello one)?
This proposal continues to allow all themes and plugins by default, but adds lines one can uncomment if they want to follow an whitelist approach per above.
Final words
I know we already have several open PRs for the WordPress gitignore, but since we don't have Issues enabled on this repo, I felt it was the best way for me to contribute to the discussion around this gitignore.