This is an example .gitignore for WordPress.
There are many different strategies for version conrolling WordPress. This gitignore is for ignoring everything except for custom build themes and plugins. This version also saved the uploads folder to git as well.
This is under the assumption that all other files (WordPress code, 3rd party plugins, node_modules) will be installed seperatly since the code for those things can be found else where.
Below theme
and custom-widget
are placeholders. Please replace them with the project theme and plugin names.
# Ignore everything in "wp-content" except these directories. #
/*
!.gitignore
!plugins/
!themes/
!uploads/
!README.md
# Ignore everything in "plugins" except certain plugins. #
plugins/*
!plugins/theme-functionality/
!plugins/custom-widget/
# Ignore everything in "themes" except the active theme. #
themes/*
!themes/theme-theme/
# Ignore packages #
themes/theme/node_modules/
# Ignore OS files #
.DS_Store
.DS_Store?
._*
.Spotlight-V100
.Trashes
ehthumbs.db
*[Tt]humbs.db
*.Trashes
# Ignore logs and databases #
*.log
*.sql
*.sqlite
error_log
access_log