DEV Community

Cover image for Visual Studio: Add your Project to Github
Olabamiji Oyetubo
Olabamiji Oyetubo

Posted on

Visual Studio: Add your Project to Github

Hi everyone,

Today I'll show you how to add your local solution file to a remote repository in GitHub, make changes, and update those changes in the remote repository. So let's begin

First, Create a new project in Visual Studio, I have created a new console application called VisualstudioGithubTest. Or you can open a previously created solution.

Next, we want to click on the Add to Source Control dropdown in the lower right-hand corner.

Add to Source Control

After that a placeholder called Git comes up, we are then going to click that.


Clicking that will bring up a screen that shows you how to create a git repository.

Create Repository
If you haven't yet connected your Visual Studio to your GitHub account, you can just click the drop-down to add an account and add your GitHub account.

Add Github Account
Then you can click on Create and Push

After that, the next thing you will notice is that your repository has been created, and your branch name is on the lower right-hand side of your screen.

Master Branch

Now let us make changes and push to that master branch.

I have changed the Program.cs to reflect a simple loop that displays numbers from 0 to 10

Great, now you can click the Git changes pane at the right of your screen.

Changed code

You can then write a commit message in the text field that says Enter a message. Since we are only changing the Program.cs file, we can simply click the Commit All button.

Commit Message

After doing that, a small pop notification shows up to tell you the commit has been created locally.

Commit created locally

Next, we want to push our changes and update the remote branch with what we have changed locally, so go ahead and click the push arrow, which is the arrow pointing up with an underscore on it.

Push Changes

And that's it! We're done. You can click on the Create a Pull Request button to take you to your online repository on GitHub to see your changes.

Pushed to master

I hope you found this useful, Happy coding everyone.

Top comments (0)