Question

As stated here one can change the name of a project. However, it only changes the name of the project and it will not change the folder structure.

As an example if your project is called sample1 and it resides ~/user1/development/IdeaProjects/sample1, the folder location won't be changed to ~/user1/development/IdeaProjects/sample2 if one changes the project name to sample2.

Was it helpful?

Solution 2

It seems that one has to right click on the project (after following the instructions to rename the Project), then choose Refactor -> Move to relocate project to the new location. I didn't find any solution to rename and move a project at once.

OTHER TIPS

  1. Right click on project, then Refactor -> Rename... (shift+F6), set desired name
  2. Close IntelliJ
  3. Rename directory in your filesystem to your desired name
  4. In startup dialog select Open (or File -> Open... in main window)
  5. Please select renamed project directory

Enjoy, it work's for me!

  1. Close IntelliJ
  2. Rename the folder in Explorer (Windows) / Finder (OSX)
  3. Open IntelliJ
  4. Import Project from Dialog, or File -> Import Project
  5. Select the folder with the new name
  6. Follow the dialogues

If it is a gradle project, instead of renaming it using Refactor->Rename :

  • set the rootProject.name variable in the settings.gradle file to the new project name.
  • reimport the project. Hit the 'Refresh all Gradle Projects' button in the Gradle Tool Window.

Then follow steps 2 to 5 in @Dawid's answer.

To remove the old project from IntelliJ's list of managed projects:

  • select File->Open Recent->Manage Projects..
  • click the 'x' next to the old project name
  1. Go to File then Project Structure
  2. Under Project Settings -> Project make sure that you change the project name.
  3. Then under Project Settings -> Modules change the name there as well.
  4. Restart Intellij
  5. Use your File Explorer to confirm that the project/modules have been renamed.

After renaming the project folder of a Kotlin project in IntelliJ, using the Import Project option as suggested in the other answers created module related problems for me. I was not able to select Main class in the Run dialogue. To solve this, I used Create New Project option. It doesn't delete your project files.

So to rename the folder, first create a copy of your project for safety and then follow these steps:

  1. Close IntelliJ.
  2. Go to file explorer and manually rename the folder.
  3. Open IntelliJ.
  4. Choose the option Create New Project
  5. Select your desired language/framework e.g. Kotlin, click Next
  6. For Project Name, specify your desired project name. Maybe same as folder name.
  7. For Project Location, choose the folder that you manually renamed.
  8. Click Finish, IntelliJ will ask if you want to overwrite .idea and .iml files. Click Yes for both.

Hope that helps.

I know that probably I won't be able to help sheidaei after more than 7 years from asking question, but I hope that someone will find it useful :)
To change project directory name of a current project without closing Intellij, choose view of "Project Files" in drop-down menu in the project browser(typically on the left) instead of "Project".
How to select "Project Files" view in project browser
Then use right-click on project's directory name/path to open context menu.
Use Refactor->Rename.
Finding option "Rename" in context menu
Type in a new directory name, apply changes using button "Refactor" and that's it.
"Rename" dialog box
If you wish to change Module Name to match directory name, use Refactor->Rename option on project name in "Project" view of project browser.

For JetBrains v. 2019.2 (September 2019):

To move project directory without changing it's name:

  1. Press Alt+1 to open project structure

    • Right click on project directory
    • Go to File -> Refactor -> Move directory

    OR

    • Left click on project directory
    • Press F6

    Specify target parent directory and hit OK.

To rename project directory:

  1. Press Alt+1 to open project structure

    • Right click on project directory
    • Go to File -> Refactor -> Rename...

    OR

    • Left click on project directory
    • Press Shift+F6
  2. Select Rename directory (actually it's already selected) and hit OK.

  3. Specify new directory name.

If you need both to move project directory and to change it's name, then do the steps one after another.

After you've done renaming/moving, close the project and remove it from the recent projects list (it became non-functional and you won't need it anymore there).

Then hit "Open" and find the project directory at it's new location. Now you have your project directory moved!

The last two steps should be done with a command like Edit project or something like that, where you can directly specify project directory, but as there is no such command, you need to remove project and reopen it at it's new location instead.

A work-arround for this, if you get an error when click "projectPackage" -> Refactor -> Move, is to close Intellij, move the folder manually, and then in:

C:\Users\user.name\ .IntelliJIdea2019.1\config\options

edit the file recentProjects.xml like this, with you new path, save and close, re-open jetbrains ide and it's done.

configfile

Well, I have figured this out and I will write down a step by step guide to how to rename the project directory linked to a GitHub repo.

Situation:

  • Windows 10
  • IntelliJ project is linked with a GitHub repo
  • I want to rename the GitHub repo and the project directory name and keep all my work the same.

Solution:

  1. rename the repo on GitHub, make sure pages is still working with the new name
  2. rename the project from IntelliJ by (right-click on the parent directory -> refactor -> rename)
  3. rename the directory from IntelliJ by (right-click on the parent directory -> open module settings -> project)
    3.1. update "project name"
    3.2. update project compiler output
  4. rename the GitHub remote repo from IntelliJ by (VCS -> git -> remotes)
  5. close IntelliJ
  6. open System Explorer
    6.1. rename the project directory
    6.2. open "workspace.xml" and rename all occurrence of the old word (you might want to cut it in another place, update it, then paste it back)
  7. open IntelliJ and select import project
  8. now, everything is okay, you can use Git inside IntelliJ normally as nothing has happened!

That is it, I just made a push from IntelliJ to the renamed repo and everything works as before without any mention of the old name.

click on your project file,which is you want to move and then push F6

Close IntelliJ 
Rename the folder in Explorer (Windows) / Finder
(OSX)   
Open IntelliJ Import Project from Dialog, or File -> Import
Project     
Select the folder with the new name 
further additional steps might be required if you see your module named
as  new_modulename[parent module/old module name],
then update   
settings.gradle with new name  and reimport
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top