Reputation: 157
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?
Upvotes: 6
Views: 24534
Reputation: 183
I tried all the above advice which didn't work for me. The solution that worked for me was to use "Git Gui" to stage, commit, and push the existing project files to the new repository.
I'm sure there's a better way and good explanation for this, however I just wanted to share what did work for me in case anyone else tried the above without success.
Upvotes: 0
Reputation: 8617
(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.
Upvotes: 2
Reputation: 1911
You can add your project in your existing repository by using following steps:
Now you can add your existing repository path and working directory path.
Upvotes: 3
Reputation: 784
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
Upvotes: 2