Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
WordPress project .gitignore
# ignore everything in the root except the "wp-content" directory.
# ignore everything in the "wp-content" directory, except:
# mu-plugins, plugins, and themes directories
# ignore all mu-plugins, plugins, and themes
# unless explicitly whitelisted at the end of this file
# ignore index.php in plugins folder
# ignore all files starting with . or ~
# ignore node dependency directories (used by grunt)
# ignore OS generated files
# ignore Editor files
# ignore log files and databases
# ignore compiled files
# ignore packaged files
# -------------------------
# BEGIN Whitelisted Files
# -------------------------
# track these files, if they exist
# track these themes
Copy link

thebigtine commented Jun 16, 2020

i want to ignore dist folder in my theme.
the dist is a result of webpack build

@vanduc1102 use: wp-content/themes/my-theme/dist/*

Copy link

jasewarner commented Jun 16, 2020

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

Copy link

jasewarner commented Jun 16, 2020

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

Copy link

thebigtine commented Jun 16, 2020

@jasewarner you're welcome 😄

Copy link

vanduc1102 commented Jun 16, 2020

it doesnt work @jose,
here is my code




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

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