I am not able to ignore files which are already under version control.
The "Ignore..." entry is disabled:
1st question: Why is it disabled?
2nd: How to add files afterwards to git ignore?
Thanks a lot!
PhpStorm says: "This option is only available if a file under the Unversioned Files node is selected. Use this option to ignore the selected file if you want to leave it unversioned."
(Source: https://www.jetbrains.com/help/phpstorm/2016.3/local-changes-tab.html)
But sometimes you may have files for an initial commit, then add it to git ignore to allow local changes (for local development) while not committing / pushing this file to any repo anymore.
Another way I handle this nowadays is to add the changes with credentials to a Changelist which is not committed:
It make no sense to ignore files that are already in your version control. So you have to remove them first with:
git rm --cached filename
then that files exist locally but are removed from your repository. Then you can ignore that files.
For the first question, as you found in the link.
For the second question, if you want to ignore a file which has already version controlled by git, you should use git command to do that:
.gitignore
file. If you don’t have .gitignore
, you can use touch .gitignore
.git rm --cached filename
.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