I tried to add my solution to the local repository by selecting File|Add to Source Control, but I got the following message.
I was facing the same issue and I solved it using GitTools extension . I have the following structure for my git repository:
In my case, I just wanted to track the files in the src folder. However, my project solution files are found in the bin folder. So, everytime that I tried to create the repository using the File|Add to Source Control or simple clicking on the git icon:
I got your message:
“ Source Control - Git The current solution has projects that are located outside the solution folder.These projects will not be source controlled in Git repository. To add all the projects to a single Git repository please consolidate all projects under a single folder.”
Which I understood that because my source files in the src folder are linked to my project solution but they are not found in the project solution folder (i.e. \bin) they cannot be added to the source control using “Source Control – Git”. Probably, I understood the message in the wrong way, but my solution works.
Just let's try to double-check the path to the solution folder:
1) Right click project solution -> open folder in file explorer
2) And we can see that my project solution folder (i.e. bin folder) does not contain the src folder that I want to track. So, VS git is complaining about it.
So, I solved the problem by installing: a) Tools -> Extensions and Updates -> Git tools
Note: You will probably need to restart Visual Studio.
b) After the installation, you will have another menu: Git Tools
c) Just select: Git ini and you will have your new repository. You will not notice any particular change.
d) You can go again to the GitTools -> GitBash and just type Git Status to test:
Notice that the git repository was created in the /projects/DRRsiddonOri3/bin folder which contains the project solution.
The price to pay is that you will have to commit using Git Bash from the GitTools menu(i.e. manually from Git Bash), if it bothers you.
However, I was not able to add /src folders because it is out of the git repostiroty (/projects/DRRsiddonOri3/bin).
In my case, I needed to create the git repository in /projects/DRRsiddonOri3/
So, I follow this path: GitTools->GitBash and change the directory from /projects/DRRsiddonOri3/bin (project solution) to /projects/DRRsiddonOri3/ and create the repository
Test: Windows 10 Visual Studio Community 2017 Version 15.9.6