Thursday, April 9, 2015

Changing Version Control in IntelliJ

IntelliJ supports different types of version controlling methods. I recently had an issue of changing the version control for a project in IntelliJ. IntelliJ was showing an SVN version control, but it was not picking up the GIT version control even if all the git files were there. The solution was to edit the ".idea/vcs.xml" file.

The content was as follows.
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
    <component name="VcsDirectoryMappings">
        <mapping directory="$PROJECT_DIR$" vcs="svn" />
    </component>
</project>
I modified it to the following.
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
    <component name="VcsDirectoryMappings">
        <mapping directory="$PROJECT_DIR$" vcs="Git" />
    </component>
</project>
Then I reopened the project in IntelliJ and was able to see the GIT sub menu in the VCS menu.

The content in the vcs.xml file might be different depending on the project.

Recently one of my colleagues was having the same issue. In his vcs.xml file, There were several mappings all directed to "svn". We changed to "Git" and reopened the project. An error notification started appearing at the top right corner mentioning a version control error and there was a link as "configuration". Once clicking the link it showed the "Version Control" of the project. We removed the broken mappings and added a new mapping with GIT. We checked the vcs.xml file afterwards, it was as following.
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
    <component name="VcsDirectoryMappings">
        <mapping directory="" vcs="Git" />
    </component>
</project>
The Git menu also came up in the VCS menu in IntelliJ.

Please note that I haven't tested with other version control methods in IntelliJ. This is just sharing hick-ups I had during coding. :)

No comments:

Post a Comment