Search code examples
gitcmakevisual-studio-2022

How to use Visual Studio Git feature with C++ CMake project


I am working in a project that uses CMake to generate a solution file for Visual Studio. As a result, in one directory I have all my source files and in the other directory there is my build with .sln file.

How can I attach Visual Studio Git to such a project in a single solution?

Note: When I chose git > local repositories in menu I am able to open the code of my project and use git feature. The problem is, that in such a way a new project is being open (I can't intrude changes and complile them in a single Visual Studio instance)


Solution

  • Step 1: Go to Git > Settings > Git Global Settings.
    Step 2: Set option: Close open solutions not under Git when opening a repository to NO.

    Now you are able to press: Git > Local Repositories and open your Git information inside your instance of Visual Studio.