I just noticed that when I have unversioned files or whole directories in IDEA, if I specify to have those files or directories ignored by right clicking and selecting ignore, they're not added to .gitignore.
How does IDEA manage that list then? It seems to recognize changes to .gitignore, so why not add ignored files to .gitignore too? I'm just thinking if someone forks my repo, or I start working with another developer, they'll potentially push files that I asked IDEA to ignore.
Thanks.
IntelliJ, however, adds its own mechanism to ignore files:Window "Version Control", Tab "Local Changes", Button "Configure Ignored Files" (on the left). IntelliJ simply never performs a "git add" for files ignored in that way. Note that this is NOT the same as Git's "gitignore".
. gitignore only ignores files that are not part of the repository yet. If you already git add ed some files, their changes will still be tracked. To remove those files from your repository (but not from your file system) use git rm --cached on them.
In project view dialog, right click on any file / directory to add that file or directory to . gitignore for the project. If a . gitignore file does not exist for the project, it will be created.
Git has its standard mechanisms to ignore files, basically:
IntelliJ, however, adds its own mechanism to ignore files:
Window "Version Control", Tab "Local Changes", Button "Configure Ignored Files" (on the left). IntelliJ simply never performs a "git add" for files ignored in that way. Note that this is NOT the same as Git's "gitignore". The effect inside IntelliJ is the same, but it is not very transparent what is going on - as mentioned in the IDEA issue linked in the comment by CrazyCoder.
On the Git command line a "git status" will show the "IntelliJ-ignored files" as "Untracked files" (use "git add ..."). If they are directories, "git status" will not even mention files contained in them because the directory is already "untracked".
Properly "Git-ignored" files do not show at all with "git status", i.e. no suggestion to use "git add ...".
The best strategy probably is to never use IntelliJ's ignore mechanism and to rely on Git's gitignore alone. For a Maven project in IntelliJ I am currently using these lines in a private gitignore file pointed at by the Git configuration variable "core.excludesfile":
/.idea/
target/
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