Search code examples
gitversion-controlgithubprojects-and-solutionsvisual-studio-2013

Committing a project instead of the solution - with VS2013 and GIT


I am using Visual Studio 2013 to develop a project of mine, which uses a source control (git). Being completely new to both git and source control, I am having some issues with the directory structure when I commit and push my changes to my GitHub project page.

Lets say that my project is named PRJ. The solution is also named PRJ, so on my local harddrive I have the following directory structure:

  • PRJ (solution folder)
    • Debug (debug output)
    • PRJ (project folder)

When I create my project on GitHub, with the same name, I get a root directory with the name PRJ. But the issues appear when I commit my project, because VS2013 commits the whole solution to the GitHub project page, which leads to a very redundant directory structure, namely:

  • PRJ (GitHub root folder)
    • PRJ (project folder)
  • Readme.md

Where as I want the content of the project to be pushed directly to the GitHub root folder (e.g pushing the project instead of the solution). Is there any easy fix for this? I do not care if the git history is lost, since I have only done very few commits.


Solution

  • When creating your project you can uncheck the "Create Solution folder" which will place the .sln file in the same folder as your project. I don't recommend this though, as you'll, at some point, will probably want to add a Unit test project or refactor some functionality into a re-usable class library, at which point your solution file will be in an awkward place (inside the folder containing your first project).

    You can also force Visual Studio to create a new project file by deleting the old one and then opening the .csproj file. Upon save, Visual Studio will prompt you whether you want to save your solution and where.