[英]How to rename / move a project in Intellij Idea 12?
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.例如,如果您的项目名为 sample1 并且它位于 ~/user1/development/IdeaProjects/sample1,则如果将项目名称更改为 sample2,文件夹位置将不会更改为 ~/user1/development/IdeaProjects/sample2。
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.似乎必须右键单击项目(按照说明重命名项目后),然后选择 Refactor -> Move 将项目重新定位到新位置。 I didn't find any solution to rename and move a project at once.
我没有找到任何可以立即重命名和移动项目的解决方案。
Enjoy, it work's for me!享受,它对我有用!
If it is a gradle project, instead of renaming it using Refactor->Rename :如果它是一个 gradle 项目,而不是使用Refactor->Rename 重命名它:
rootProject.name
variable in the settings.gradle file to the new project name.rootProject.name
变量设置为新项目名称。 Then follow steps 2 to 5 in @Dawid's answer .然后按照@Dawid 的回答中的步骤 2 到 5 进行操作。
To remove the old project from IntelliJ's list of managed projects:从 IntelliJ 的托管项目列表中删除旧项目:
File
then Project Structure
File
然后是Project Structure
Project Settings -> Project
make sure that you change the project name.Project Settings -> Project
确保更改项目名称。Project Settings -> Modules
change the name there as well.Project Settings -> Modules
更改名称。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.在 IntelliJ 中重命名 Kotlin 项目的项目文件夹后,使用其他答案中建议的导入项目选项为我创建了与模块相关的问题。 I was not able to select Main class in the Run dialogue.
我无法在 Run 对话框中选择 Main 类。 To solve this, I used
Create New Project
option.为了解决这个问题,我使用了
Create New Project
选项。 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:因此,要重命名文件夹,请先创建项目的副本以确保安全,然后按照以下步骤操作:
Create New Project
Create New Project
Kotlin
, click Next
Kotlin
,点击Next
Project Name
, specify your desired project name.Project Name
,指定所需的项目名称。 Maybe same as folder name.Project Location
, choose the folder that you manually renamed .Project Location
,选择您手动重命名的文件夹。Finish
, IntelliJ will ask if you want to overwrite .idea
and .iml
files.Finish
,IntelliJ 会询问您是否要覆盖.idea
和.iml
文件。 Click Yes
for both.Yes
。 Hope that helps.希望有帮助。
For JetBrains v. 2019.2 (September 2019):对于 JetBrains v. 2019.2 (2019 年 9 月):
To move project directory without changing it's name:要移动项目目录而不更改其名称:
Press Alt+1
to open project structure按
Alt+1
打开项目结构
OR要么
F6
F6
Specify target parent directory and hit OK.指定目标父目录并点击确定。
To rename project directory:重命名项目目录:
Press Alt+1
to open project structure按
Alt+1
打开项目结构
OR要么
Shift+F6
Shift+F6
Select Rename directory (actually it's already selected) and hit OK.选择重命名目录(实际上它已经被选中)并点击确定。
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.最后两个步骤应该使用像 Edit project 或类似的命令来完成,您可以在其中直接指定项目目录,但由于没有这样的命令,您需要删除项目并在新位置重新打开它。
单击您要移动的项目文件,然后按 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
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:对此的解决方法是,如果在单击“projectPackage”-> 重构-> 移动时出现错误,请关闭 Intellij,手动移动文件夹,然后在:
C:\\Users\\user.name\\ .IntelliJIdea2019.1\\config\\options
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.像这样编辑文件recentProjects.xml,使用新路径,保存并关闭,重新打开jetbrains ide,就完成了。
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.好吧,我已经弄清楚了,我将写下有关如何重命名链接到 GitHub 存储库的项目目录的分步指南。
Situation:情况:
Solution:解决方案:
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.就是这样,我只是从 IntelliJ 推送到重命名的 repo,一切都像以前一样工作,没有提及旧名称。
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 :)我知道在提出问题超过 7 年之后,我可能无法帮助 sheidaei,但我希望有人会发现它有用:)
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".要在不关闭 Intellij 的情况下更改当前项目的项目目录名称,请在项目浏览器(通常在左侧)的下拉菜单中选择“项目文件”视图而不是“项目”。
How to select "Project Files" view in project browser如何在项目浏览器中选择“项目文件”视图
Then use right-click on project's directory name /path to open context menu.然后使用右键单击项目的目录名称/path 打开上下文菜单。
Use Refactor->Rename .使用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.如果您希望更改模块名称以匹配目录名称,请在项目浏览器的“项目”视图中的项目名称上使用 Refactor->Rename 选项。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.