How do I add an existing Solution to GitHub from Visual Studio 2013

I have looked through many web pages on the new Git integration in VS 2013 and they do not deal with adding an existing solution to Github. In fact I can’t find much on using GitHub instead of Visual Studio Online.

Can anyone tell me how I start from an existing solution and add it to Github using the tools in VS 2013.

Please don’t just post links as I have read most of them.

How do I copy a web reference from one solution to another in Visual Studio 2013

I’m using a RateServiceWebReference Web Reference in one solution that I downloaded from FedEx’s Rate Web Service. It’s a console application and I have it wired up so that everything works nicely (in

How to add an existing folder to F#.NET project in Visual Studio Ultimate 2013?

I would like to add an existing folder to my F#.NET project in Visual Studio Ultimate 2013. Several Stackoverflow questions deal with the issue, most of them mentioning a mythical ‘Show All Files’ ic

How do I convert an existing makefile for Visual Studio back into a solution file (*.sln)?

I would like to open an existing Visual Studio project in Visual Studio, so I can change some parameters. However, I only have the makefile (which I can compile without any problems with nmake). How w

Remove Git binding from Visual Studio 2013 solution?

I was adding a new Solution to TFS in Visual Studio 2013, and I selected Git as opposed to TFS. I want to remove the Git binding, and add TFS. I know you can remove TFS binding from File -> Source

Visual studio 2008 adding existing project to main solution

I have a main visual studio solution and other solution.(VS 2008) I want to add a project from other solution. If I use Add Existing Item visual studio create a reference to that project from main s

Change the visual studio solution file from 2013 to 2010

I have a project that I made in Visual Studio 2010 earlier before Visual Studio 2013 came out. After visual studio 2013 come out, I uninstalled Visual Studio 2010 and opened the project in Visual Stud

How do I add a folder, not a “filter”, in Visual Studio 2013?

I have a Visual Studio 2013 project within a folder called ‘Source’, let’s say. I’d like to have some additional folders within that folder and I’m trying to find a way to do that. If I, in visual stu

How do I get latest from a Visual Studio solution from the command line?

How do I get the latest version of my solution recursively like its done in the solution explorer context menu of Visual Studio? I want to do this from the command line or via a macro. I’m trying to a

How do I integrate StyleCop 4.7 with Visual Studio 2013?

I really want to use StyleCop with my Visual Studio 2013, but unfortunately it won’t work. I’ve installed the 4.7 version from the official site, checking all options, both VS Studio integration and M

How can i install MonoGame into Visual Studio 2013?

How can I install MonoGame templates for Visual Studio 2013?

Answers

  • From the Team Explorer menu click “add” under the Git repository section (you’ll need to add the solution directory to the Local Git Repository)
  • Open the solution from Team Explorer (right click on the added solution – open)
  • Click on the commit button and look for the link “push”

Visual Studio should now ask your GitHub credentials and then proceed to upload your solution.

Since I have my Windows account connected to Visual Studio to work with Team Foundation I don’t know if it works without an account, Visual Studio will keep track of who commits so if you are not logged in it will probably ask you to first.

OK this worked for me.

  1. Open the solution in Visual Studio 2013
  2. Select File | Add to Source Control

That creates a local GIT repository

  1. Surf to GitHub
  2. Create a new repository DO NOT SELECT Initialize this repository with a README

That creates an empty repository with no Master branch

  1. Once created open the repository and copy the URL (it’s on the right of the screen in the current version)
  2. Go back to Visual Studio
  3. Open Team Explorer
  4. Select Home | Unsynced Commits
  5. Enter the GitHub URL into the yellow box
  6. Click Publish
  7. Select Home | Changes
  8. Add a Commit comment
  9. Select Commit and Push from the drop down

Your solution is now in GitHub

Make sure you enter correct publish link .Otherwise it will stuck up and you have to start adding repository again.

This question has already been answered accurately by Richard210363.

However, I would like to point out that there is another way to do this, and to warn that this alternate approach should be avoided, as it causes problems.

As R0MANARMY stated in a comment to the original question, it is possible to create a repo from the existing solution folder using the git command line or even Git Gui. However, when you do this it adds all the files below that folder to the repo, including build output (bin/ obj/ folders) user options files (.suo, .csproj.user) and numerous other files that may be in your solution folder but that you don’t want to include in your repo. One unwanted side effect of this is that after building locally, the build output will show up in your “changes” list.

When you add using “Select File | Add to Source Control” in Visual Studio, it intelligently includes the correct project and solution files, and leaves the other ones out. Also it automatically creates a .gitignore file that helps prevent these unwanted files from being added to the repo in the future.

If you have already created a repo that includes these unwanted files and then add the .gitignore file at a later time, the unwanted files will still remain part of the repo and will need to be removed manually… it’s probably easier to delete the repo and start over again by creating the repo the correct way.

My problem is that when i use https for the remote URL, it doesn’t work, so I use http instead. This allows me to publish/sync with GitHub from Team Explorer instantly.