Adding GIT support to existing project in IntelliJ

2019-02-02 21:14发布

问题:

I have multi-module project built with Maven. I imported only single sub-module (not parent) from that project as IDEA project, and looks like IDE doesn't recognize .git folder (because it is one level up from project root I used to import, I guess)

Is there still a possibility to add Git support for intelliJ somehow?

回答1:

I have successfully opened a Maven subproject within IDEA. Naturally, it hasn't enabled Git integration automatically. From VCS menu I have selected "Enable Version Control Integration" and chose "Git" from submenu.

Then IDEA complained that there is no .git folder within the project and offered to select parent .git folder. I did it and everything worked as expected.

If you don't have Git option in VCS menu, this might be a bug. Try to disable SVN plugin and see if that helps (I don't have SVN plugin in my IDEA).



回答2:

You may need to add git to the list of version control in the settings

settings > Version Control

then make sure that git is listed in the table as a VCS

I had to do this otherwise git wasn't listed in the VCS menu in the menu bar.



回答3:

Not sure if it's helpful to anyone else, but in my case, we had recently upgraded from CVS to GIT (gasp). There were some old CVS specific files in the project (i.e. .cvsignore) that must have indicated to IntelliJ that this was a CVS project. I had to manually remove this file for IntelliJ to recognize the new .git folder and related files.



回答4:

In my case, I was not able to get Intellij to detect Git on the module. So I removed the module from the project and re-added it. That time it was detected and I could use the Git menu.



回答5:

If your issue is that the Version Control tab is missing use View/Tool Windows/Version Control.

This will bring the Version Control window into the bottom frame, provided all the remaining pieces of your git configuration are correct.



回答6:

Consider using Git outside of the IDE. There are great efficiencies to be gained from the command line in Git.