Search code examples
gitvisual-studiogithubvisual-studio-2017

Add a visual studio project to an existing git repository


I have a project that I have started in visual studio and would like to add it to an existing GitHub repository. I am using visual studio 17 and I have installed the github extension for visual studio. I have synced the repo with visual studio and the added the project to source control. There is the option to publish to GitHub but looks like it creates a new repository. Is there any way to add a project to an existing GitHub repository?


Solution

  • I'm not familiar with VS git...but in CLI git, you should be able to run git remote add origin <path to github repo>. Whenever you push and pull, it will impact that repository

    If this is a more carefully managed repo and code is merged via pull requests, you would want to create your own github repo as VS is doing, and then add the original repository as upstream. Basically the same thing: git remote add upstream <path to organization's repo>

    If you don't see a way to add upstream or run command line from visual studio plugin, you'll have to download the git command line tools https://git-scm.com/download/win. If it's installed correctly, you should be able to run git and see a bunch of usage instructions come up. If your project is already a git repo, the top of that project directory should have a .git folder. You can run the commands I listed from anywhere within that project directory