DEV Community

xarzu
xarzu

Posted on

How do I connect my existing Visual Studio 2022 project to an existing github repository?

I set up a github repository to match the project I am working on in Visual Studio 2022. I did something wrong and only the project file exists. I followed a tutorial. But the tutorial was disappointing and the instruction was to drag the content of my project and I suppose I only uploaded the project file.

That was then. This is now. So far this is what I have done. In Visual studio I opened a command window by click on CTRL + `. THen using the.git file and its location from my github repository, I typed at the command line:

** Copyright (c) 2022 Microsoft Corporation


PS C:\source\repos\SharePointListCreation> git clone https://github.com/Wm-M-Thompson/SharePointListCreation.git
Cloning into 'SharePointListCreation'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
Receiving objects: 100% (3/3), done.
PS C:\source\repos\SharePointListCreation>

That is the result if me putting "git clone https://github.com/Wm-M-Thompson/SharePointListCreation.git" at the command line window inside Visual Studio.

I asked AI and this is what they suggested:

Image description

As the case sometimes is, following the direction of AI does not result in positive results. When I right-clicked on the solution, the option to "Add Solution to Source Control" did not appear. Instead, I got this:

Image description

Now, when I click on this, option to "Create Git Repository..." I am not able to set up a GitHub connection because the system recognizes that it already exists and the "Create and push" button is greyed out, but when pick "existing remote" I am able to make the connection and (supposedly) push my code to github.

Image description

Image description

This seems to work. There is a notice that appears in the IDE in the bottom left that suggests that the files is being uploaded to the github repository.

Image description

On github there seemed to be the files there but, at the same time, when I look closer at the content, the files were NOT there. Anyway, here is a screen shot of what looks like the files ARE there:

Image description

So I uploaded the .cs and .sln files by hand. Now, how do I do periodic pushes and updates to github from my Microsoft Visual Studio 2022 IDE?

Top comments (0)