Why Magento 2 .gitignore File Ignores Itself – Explanation

gitmagento2

Line 61 of the .gitignore file reads

/*.*

which includes itself so the .gitignore file is not committed. Is there a reason behind this?

https://github.com/magento/magento2-community-edition/blob/master/.gitignore

Best Answer

Obviously not because it already has been committed the repository and as such, will not be ignored anymore.

.gitignore only applies to files that are not added yet, so even if you make changes to the file, Git will show it as unstaged changes and they will be included in a commit after staging.