Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
WordPress project .gitignore
# 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/themes/*
# ignore index.php in plugins folder
wp-content/plugins/index.php
# 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
*.codekit3
.idea
# 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
!.scss-lint.yml
!README.md
!CHANGELOG.md
!composer.json
# track these themes
!wp-content/themes/theme_name/
@jasewarner
Copy link
Author

jasewarner commented Jun 16, 2020

@mikedamoiseau, I've added .idea. Thanks for the suggestion.

@jasewarner
Copy link
Author

jasewarner commented Jun 16, 2020

@josephbydeign, a (very) belated thanks for the *.codekit3 suggestion and also for helping out @vanduc1102.

@thebigtine
Copy link

thebigtine commented Jun 16, 2020

@jasewarner you're welcome 😄

@vanduc1102
Copy link

vanduc1102 commented Jun 16, 2020

it doesnt work @jose,
here is my code

wp-content/*
!wp-content/mu-plugins/

!wp-content/plugins/
wp-content/plugins/*
!wp-content/plugins/p-a/

!wp-content/themes/
wp-content/themes/*
!wp-content/themes/theme-a/
wp-content/themes/theme-a/dist/*
!wp-content/themes/theme-b/

After commit the .gitignore and run git update-index
I'm still seeing files in dist/* as tracked
------- UPDATED --------
my bad, the dist was tracked, I need to delete the dist folder and commit them,
the code above works well, thanks @josephbydeign

@michael-sumner
Copy link

michael-sumner commented Feb 2, 2022

For those of you having issues with the gitignore still not working. The reason is because the git has cached that gitignore.
So what you should do is clear the gitignore cache within your git installation, by doing so:

git rm --cached -r . && git add .

That way you can ensure that if you want to ignore a file but it is not working, then the reason is because gitignore has cached that file to still be present in your future commits. By clearing the gitignore cache you are able to effectively ignore the files to follow your gitignore.

Yes, I said gitignore 7 times.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment