Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In IntelliJ, How Do I Fix "These Files Do Not Belong to the Project"?

I recently put several old, yucky git directory structures into one new, clean structure in SVN, then pulled the entire SVN repository back out into a new, clean, local git repository. One IntelliJ project was so messed up I had to import the old IntelliJ project, which created a new .iml file having a better name, and deleted the old .iml file. I reconfigured everything, committed back into SVN, and verified other people could open the project and build.

Today I tried to edit a file for the first time in this project and got the message, "These files do not belong to the project". IntelliJ offers to unlock the file or all non-project files in the current session, but both options sound wrong. What have I done to myself, and how do I fix it?

like image 934
Jim L. Avatar asked Jan 22 '15 22:01

Jim L.


People also ask

How do I link a file to a project in IntelliJ?

In the Project tool window, right-click the Project toolbar and, from the context menu, select Always Select Opened File . After that IntelliJ IDEA will track the file that is currently opened in the active editor tab and locate it in the Project tool window automatically.

How do I change project settings in IntelliJ?

To configure project settings, select IntelliJ IDEA | Preferences on macOS or File | Settings on Windows and Linux from the main menu. Alternatively, you can press Ctrl+Alt+S to show the IDE settings. icon. Other settings are global and apply to all existing projects.


2 Answers

This happened for me when I ignored the .idea/ files. Just do

rm -rf .idea/ 

And then File -> Invalidate Caches/Restart -> Invalidate And Restart.

like image 74
Sidonai Avatar answered Sep 21 '22 06:09

Sidonai


I figured out the problem. The file was still open from before all the shuffling, and was apparently pointing at the original file in its original location! I closed the editor and reopened the file from the project tree without a problem. I hope this helps someone else someday.

like image 21
Jim L. Avatar answered Sep 22 '22 06:09

Jim L.