When using git with Wordpress project, what will be recommended settings for .gitignore file?
gitignore should list the names or name-patterns of files that will be found in work-trees when working with your project, but that should not be committed to the project. In other words, it's not OS-specific, it's project-specific.
If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a .gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.
gitignore file is a plain text file that contains a list of all the specified files and folders from the project that Git should ignore and not track. Inside . gitignore , you can tell Git to ignore only a single file or a single folder by mentioning the name or pattern of that specific file or folder.
Posting this as an answer because it seems I can't comment on answers.
I suggest the following (based on Dales answer):
.htaccess
wp-config.php
wp-content/*
!wp-content/themes/
!wp-content/plugins/
sitemap.xml
*.log
sitemap.xml
sitemap.xml.gz
What it does is that it first ignores everything within wp-content but then makes exceptions for the wp-content/themes/ and wp-content/plugins/ folders.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With