'work on two branches on the same project in intellij idea

I would like to work on two separate branches in my idea project.

An easy solution would be:

Clone the git directory (a second time) in my project folder and checkout the git required branch. This is not working in idea, the git copy does is not recognized as git folder.

The repository is not in project root, current structure:

ProjectFolder/
ProjectFolder/gitRepository
ProjectFolder/gitRepositoryClone


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source