vatzec
vatzec

Reputation: 403

Import an existing Git repository into IntelliJ IDEA

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!

Upvotes: 28

Views: 85525

Answers (5)

Andrey Cizov
Andrey Cizov

Reputation: 703

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).

Upvotes: 2

ryenus
ryenus

Reputation: 17431

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.

Upvotes: 4

Cari
Cari

Reputation: 1007

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.

Upvotes: 13

Ryan Walls
Ryan Walls

Reputation: 7092

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.

Upvotes: 3

Prasanna
Prasanna

Reputation: 11544

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.

Upvotes: 11

Related Questions