Add a visual studio project to an existing git repository
Solution 1
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
Solution 2
You can add your project in your existing repository by using following steps:
- Go to Team Explorer in VS
- Select Manage connection
- Click on clone button
Now you can add your existing repository path and working directory path.
Solution 3
(VS2019)
In the git portion of Visual Studio, click whatever is at the top to get to the main menu, go to settings.
In the settings, you should see remotes --- add a new one, or as seen here I already added a remote "origin."
Finally you can just paste in the github link, and then sync/push your changes.
Rory Danes
Updated on June 14, 2022Comments
-
Rory Danes almost 2 years
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?