Import an existing Git repository into IntelliJ IDEA

假如想象 提交于 2020-05-09 18:57:08

问题


I have a local Git repository with my own branches, stashes and all that jazz, and I'd like to add this repository into IntelliJ IDEA, so that I can manage it, instead of creating a new copy of the repository from within IDEA. How do I do that?

Thanks!


回答1:


The ideal way is to open the directory in Intellij,not trying to import it from repo. When you open the directory as project, Intellij will ask whether you need to configure VCS.

Or even after creating a project in Intellij,you can goto VCS menu and include into Git repo.




回答2:


You can actually use an existing repo. Just go to Open and open the directory that you want to be your root. Then select the git repo directory, go to the VCS menu, and select Enable Version Control Integration.

That's all it took me. That was how easy it was on a Mac. Not sure if the flow is exactly the same on other platforms.




回答3:


Essentially it's just two steps:

  1. Specify VCS root,

    This should be done in Preferences (⌘,) > Version Control

  2. Enable Version Control Integration

    if you can find this option in Menu > VCS, good luck, just click it. Otherwise, select Menu > Help > Find Action...(⇧⌘A), then type Enable Version Control Integration, and just press the Enter key.




回答4:


When you start up intellij and no projects are open, there is a dialog option to "import from VCS". Choose that instead of create new project or import project.




回答5:


On the latest version of IntelliJ IDEA, when the project contains more than one module and one of the modules is already tied to VCS integration, the VCS > Enable Version Control Integration menu will not appear. This happens in the case when one of the modules was missing a relevant .git directory before the integration was added to the project.

Solved by browsing to the relevant project's .idea/vcs.xml file and then adding another line such as:

<mapping directory="$PROJECT_DIR$/../project_name" vcs="Git" />

The changes should immediately reflect in the UI (e.g. changed lines will be highlighted).



来源:https://stackoverflow.com/questions/15571451/import-an-existing-git-repository-into-intellij-idea

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!