Idea-gitignore: "Add to .gitignore" option missing from context menu

Created on 9 Jun 2015  路  20Comments  路  Source: JetBrains/idea-gitignore

I have a project with multiple repositories set up (for different modules) - don't know if this is relevant, but I don't get the context menu option "Add to .gitignore" for any of my files within the PSI tree. Using newest plugin and IDEA release build. Tried disabling all other plugins, still happening.

cannot reproduce

Most helpful comment

This is an issue if you add a maven module to an existing one.
For example, if you 'open' a maven project it is added to the project view. If you then through the maven projects view add another project (via the green plus icon), the context menu doesn't appear for any files in the newly added project, but it does for the original.
In my experience the 'hide ignored files' doesn't work on these added projects either.

To recreate:

  1. open a new project in IntelliJ
  2. in the maven projects view add a new project (this will cause the project to appear in the project view (alt+1)
  3. any files in the original project (from point 1 above) will have the "add to .gitignore" context menu option, but files in project from point 2 above will not.
  4. files in project 2 will not auto-hide when already in the .gitignore file and looking in the project view

The above was confirmed using latest IntelliJ (2017.2.3 build #IC-172.3968.16) and latest .gitignore plugin (v2.1.1) versions

All 20 comments

@pwilkin Do you have any of *ignore file in your project ? Can you provide me more details about your case ?

Yes, I have quite a few of them. At least one per VCS root. What would you like to know?

(I can provide you with any debugging info you want if you need it)

I'll try to give as much relevant info that I can think of:

  • I made certain that the plugin loaded correctly. The icon near .gitignore files changed, I have the custom editor for .gitignore files, have the add .gitignore file action etc.
  • Happens on both my IDEA installations, both on my laptop and my desktop. They share a similar project structure
  • My project has multiple modules, each of them corresponding to a single project imported from Eclipse. They are all grouped within module groups.
  • Each module has its separate VCS root. The root of the module is the root of the respective VCS (I have a single module on my desktop which does not conform to this rule)
  • Each module has a .gitignore file in its root directory and at least one other .gitignore file somewhere else in the structure
  • The .gitignore file itself is ignored
  • All the .gitignore entries are marked gray an the inspection reports they are "never used"
  • The .gitignore file itself is ignored

Will it work properly if you remove this rule ?

@pwilkin Can you verify it with the latest v1.3.3 version ?

Yes, it still persists (the context option is still missing).

I might try to debug it if I get some free time.

Also, if it is of any help: the relative paths are recognized properly in the .gitignore file (marked as green). the absolute paths are not (marked as gray). So for example, if I have a .gitignore file in the root of my module VCS, then a "bin" entry is recognized properly, but a "/logs/" one is not.

I am using v1.4.1 with the latest IntelliJ IDEA, and I do not have this option as well.

Can confirm the issue aswell, context menu entry is missing.

This is also an issue in Rider.

Can I ask you to check if this issue is still present in v2.1.1?

This is an issue if you add a maven module to an existing one.
For example, if you 'open' a maven project it is added to the project view. If you then through the maven projects view add another project (via the green plus icon), the context menu doesn't appear for any files in the newly added project, but it does for the original.
In my experience the 'hide ignored files' doesn't work on these added projects either.

To recreate:

  1. open a new project in IntelliJ
  2. in the maven projects view add a new project (this will cause the project to appear in the project view (alt+1)
  3. any files in the original project (from point 1 above) will have the "add to .gitignore" context menu option, but files in project from point 2 above will not.
  4. files in project 2 will not auto-hide when already in the .gitignore file and looking in the project view

The above was confirmed using latest IntelliJ (2017.2.3 build #IC-172.3968.16) and latest .gitignore plugin (v2.1.1) versions

I can confirm the bug description by @themoffster with the latest IntelliJ (2018.1 build #IU-181.4203.550) and latest .gitignore plugin (v2.5.0) still.

This is happening to me as well now (Idea v2019.1.1 and .ignore v3.1.2.191). Tried deleting local caches and rebuilding project directories as well as having tried cloning to a new directory directly from GitHub. Cannot add files to .gitignore from the context menu and plugin also doesn't recognize files I manually add to .gitignore when trying to hide them from the project file tree tool window.

Also I encounter this problem, after reinstalling my laptop with everything freshly installed.

I only have the 'unignore' option, but none of my files can be added to the .ignore file:

image

Strange thing is that before I re-installed everything, adding did work correctly!

Here some extra info.

Plugin version:
image

PhpStorm version:

image

I just found out that the context menu does work in the case of

  • an unversioned file
  • in the 'commit' tab of PhpStorm

image

Can this function add to gitignore also be used in the 'project' tab in PhpStorm?

@ametad since 2019.2 the Add to gitingore is the platform functionality, which does not require the .ignore plugin. See #587 (comment)
It is git-related, so it is under GIt menu in the project tab.
Screenshot 2020-05-15 at 14 26 51

The unignore action comes from the plugin though, so it is in a different place. I think we will move it to the Git submenu also.

@dmitriysmirnovjb Thank you for the info. I found it!

BTW only "Unversioned Files" have the option Git > Add to .gitignore > ... Is this indeed how it suppose to be? I guess to ignore already tracked files, the should first be removed from the repo and than added to the .gitignore file. Right?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

klevie picture klevie  路  6Comments

mfursov picture mfursov  路  3Comments

hoangtranwork picture hoangtranwork  路  3Comments

Vampire picture Vampire  路  5Comments

sercheo87 picture sercheo87  路  5Comments