问题
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:
Specify VCS root,
This should be done in Preferences (
⌘,
) > Version ControlEnable 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 typeEnable Version Control Integration
, and just press theEnter
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