Kevin T
Kevin T

Reputation: 132

Add existing project to source control in Visual Studio 2017 solution using Git repo in Team Explorer

I'm struggling to add an existing DB model project to an application solution in Visual Studio 2017.

I'm using Git instead of TFVC for the repo and source control.

When I add the existing project, everything builds fine at the solution level, but when I go to add the project to the solution in source control I don't see any changes, I've gone through dozens of MS Docs and forum posts around it but can't find a solution to this particular problem.

Anyone else experience this and know a workaround? I can only find docs surrounding TFVC which is useless to me as we moved across from TFVC to Git a year ago.

Apparently the VS Dev team are aware of this but haven't done anything about it, too concerned with new frameworks to worry about their platform actually working with all the plug-ins they officially support :(

VS doesn't give me any options to "Add to source control" when I select the newly added project.

Upvotes: 3

Views: 11618

Answers (3)

RetroCoder
RetroCoder

Reputation: 2685

Found a friendly video on YouTube that's easy to understand: How To Add An Existing Project To Your GitHub Repo With Visual Studio

I think the steps are:

  1. Create a new project on your git server like GitHub or git on tfs etc..

  2. Clone the new project to your local desktop in a folder somehow.

  3. Copy all the files from your existing project making sure there is no .git in root to your new folder that you cloned which should have a .git in the root. If you don't see it its probably because the files are hidden and if you want to verify that it existing you'll have to go into file explorer and check the show hidden files option to checked.

  4. Commit the changes locally

  5. Push the changes to the origin or to the remote server... Origin is just a fancy name or qualifier for your git server that you are subscribed to like GitHub, TFS git, or your own personal git server where you set that up yourself. Just remember the client app like TortoiseGit or GitSVN is not a git server … its just your local git app for storing branches locally before you also use to push to the remote server and for pulling the latest changes from a particular branch name or revision via a guid.

  6. Git is not really something you can just get after the first use. You'll only get it after you use git like 100 times.

Upvotes: 0

Kevin T
Kevin T

Reputation: 132

So after trying everything I went back to the old VS hack of adding the project to the solution folder locally then showing all files in VS, then that allowed me to add it to the repository. Very counter intuitive, can't believe I had to resort to a hack.

Upvotes: 2

PatrickLu-MSFT
PatrickLu-MSFT

Reputation: 51073

You just need to make sure the existing project and the solution in source control you want to add, they are in the same local git repo.

Then do the git push from command line, or push/sync command in VS. The changes in local git repo will also sync with your remote git remote in TFS/VSTS source control.

Usually the "Add to source control" command will appear in the right bottom of Visual Studio. You could select the corresponding git repo.

enter image description here

Upvotes: 1

Related Questions