Search code examples
gitvisual-studiosql-server-data-tools

Git and Visual Studio/SSDT project folders


New to Git so trying to understand how to make VS work with Git. VS creates a directory for each project you create then places newly created entities within that directory. When adding an existing entity to a project VS copies it to the project directory. Seems like Git will never be able to manage your source files because VS is creating copies.

Ex. Directory structure - C:\MRepo, includes .git and src subdirectories.
src includes V1.0.0 Rpt1.rdl and Rpt2.rdl

I need to work on FeatureA so I create a branch for FeatureA and checkout FeatureA. FeatureA will have changes for Rpt1.rdl. I start by creating a new VS project and name it FeatureA, directory C:\MRepo\FeatureA is created. Since I'm revising Rpt1.rdl I "add existing" and point to Rpt1.rdl. This results in a copy being placed in C:\MRepo\FeatureA. I now have C:\MRepo\Rpt1.rdl and C:\MRepo\FeatureA\Rpt1.rdl

This doesn't seem ideal, with Git I believe we want a single source file and it will save the individual changes created. When in a branch we expect to see relevant changes that were made while in the branch, ie when FeatureA branch is checked out we should only see revisions made while within the FeatureA branch.

Can anyone shed some light on this? Really like to leverage Git for source control then ultimately hoping to develop a workflow that incorporates a release process.

Update: Thanks for the responses, this made me rethink my line of questioning. I realized my problem was really with how to use VS projects when they are under Git source control. After creating a simple example with a single project, a reportfile and commiting changes I created a branch "FeatureA". Switching to FeatureA and changing the reportfile I then committed. Switching between FeatureA and Master the reportfile correctly reflected the changes or lack of. In the past I had used various VS projects to align to features, since each project creates its own directory using the project name I'll need to figure out how multiple projects might share the same source directory.


Solution

  • Hi @bartl please do not confuse folders/directories with git branches. It has a totally different workflow altogether.

    You can think of branches as different features; create feature branch from master work on it make commit(this is important, otherwise you will be taking this feature onto other branches and will make things worse) on that feature branch.

    Once you have made commit for that specific feature you are free to move to any branch and repeat the above steps for other features.

    One thing to note here is as and when you move to other branches/feature_brances the code structure may change depending on the feature.

    Also, regarding .git, it should be present in the main project root directory only if you have not initialized git repo at multiple directories/subdirectories within root project.

    I'll recommend you to please go through this very interactive tutorial to understand very basics of git before actually using it, so that you start enjoying GIT.

    Happy coding.