Share via


How to Add a New Visual Studio Solution to an Existing VSTS Repository

You can follow instructions outlined in two articles below to create a new Git repo and run basic Git commands.

Create a new Git repo in your project
/en-us/vsts/git/create-new-repo?view=vsts

Get started with Git from the command line
/en-us/vsts/git/share-your-code-in-git-cmdline?view=vsts

To add a new Visual Studio solution to an existing repository of Visual Studio Team Services (VSTS, aka Visual Studio Online), you can use the Git add-on to Visual Studio.

Or, you can run the command lines as shown below. Note that I tested the command lines on my Windows 10 PC and Visual Studio 2017. Also, there is only one team project in the repository.

 

Step 1 – Create and complete a new Visual Studio project

For this blog post, I created a sample project called Ninja Care Twilio in Visual Studio 2017.

 

Step 2 – Locate your VSTS repository and team  project and download/create a local repo

Navigate to the location where you’d like to add the local repo for the team project, e.g. c:\users\zxue\source\repos

git clone https://<reponame>.visualstudio.com/_git/<projectname >

 

image

 

Step 3 – Add the new VS solution to the new local repo and make git aware of the changes to the local repo.

Copy the new VS solution to the local repo with Windows Explorer or command line.

In Git CMD, navigate to the local repo and check git status. You will notice the VS solution listed as “Untracked files.” The add the VS solution to the local repo and commit the changes. Note that you don’t need to run “git init .” because you have already initialized the local repo through the “git clone” command.

git status

git add --all
git commit -m "add a new VS solution"

git status

image

image

image

 

Step 4 – Sync up the changes to the team project in VSTS

git push origin master

image

You should be all set. You can browse the VSTS portal to see that the new VS solution has been added to the team project.

 

if you are not sure if you have set up the remote origin, you can run the command below.

git remote –v

If necessary, you can add a remote origin by running the command below. Replace the repository and team project name with yours.

git remote add origin https://fabrikops2.visualstudio.com/DefaultCollection/Fabrikam/_git/FabrikamApp