GitHub With Visual Studio

This article will demonstrate an open source version control and it is nothing but GitHub. We will also see what GitHub is and why we should use it. This demonstration will show you, how to publish your project on GitHub with Visual Studio 2015.

What is GitHub?

It is a version control, which provides us a centralized location, where we can publish our working code or project and share it with the other developers. Basically, GitHub is an open source version control for the developers, programmers and designers, so that they can publish and keep track of the changes, when a new version releases for the projects. It is free and can be downloaded from GitHub.

Why GitHub

If you are a developer or a programmer, on a daily basis, you do some codes. Thus, it will be a better solution for you, if you store your code/project somewhere, whether it is accessible to everyone or private. Thus, GitHub is there. On GitHub, you can store your codes/projects and share it publicly to help others. If you have shared your project publicly, anyone can download it and use it.

It also very helpful, when you make any changes in your existing code and keep track of changes to the release with different versions. It works on Repository, so if you make any changes in Repository, it can be tracked.

Here, you can store the code files, folders, images, videos and any other resource files. You can also publish a ReadMe file, which stores the basic information for your project.

Create GitHub Account

To access GitHub, first you need to create a GitHub account from this link. Here, you can choose your display name and provide your Email ID for sign up.

sign up

When you sign in with your credentials, it will show you the profile page on GitHub. Here, you can create Repository, as given below-

credentials

Add Visual Studio Project in GitHub

Now, it is time to create a project inside Visual Studio and publish it in GitHub. Thus, I have created a dummy project only for demo purposes in Visual Studio 2015. It is a WinForm Application and nothing else.

Add Visual Studio Project

Now, right click on the solution [GitHub Demo] and it will provide a "Add Solution to Source Control" option. You need to click this to add this project in GitHub. As I have said earlier, it is nothing but a source control to add the projects.

solution

It will provide a "Choose Source Control" popup, where you can choose Git as a source control. Other option is for TFS. For TFS, I will be discussing in my next article. Thus, choose GitHub and click OK.

Choose Source Control

NOTE: If you are not getting Git option, please Go to https://visualstudio.github.com/ and download the extension for Visual Studio.

extension

After choosing a Git, it will add some Git related folders in your local project repository, as shown below-

Git related folders
Gives you few options like "Changes", "Branches", "Sync" and "Settings".

options

Here, you need to select the changes, which shows all the required changes in the project. For the first time, it will show all the project files, as required to check in Source Control. You need to provide the description to add the code in Source Control and hit to execute commit option.

commit

After committing, it will commit your code in the local repository as respective to your project and it will ask to you to make your project in Synchronization with the Server repository. Thus, just click on Sync to make these changes in the Server.

Sync

When you choose Sync option to make your code changes on the Server repository, it will ask the Server repository path, as image is shown below. Thus, you need to pass the Server repository path here and click publish.

publish

If you have not created a repository on the Server yet, just login with GitHub and create a New Repository to click New Repository button, as  shown below-

Repository

To create a new repository, provide the repository name, description and you can also choose your repository accessibility as Public or Private and click New Repository button.

Repository

When a new repository is done, it will give you a repository path, shown in the image, given below, in Yellow. Just copy the path.

path

Just paste the copied link inside the Publish to Remote Repository section and click Publish button to publish repository with the Server Repository.

 Publish to Remote Repository

After clicking Publish, it will be published in your project in master branch. Master branch is a default branch for GitHub Source Control. You can also create na ew one for your requirement.

Publish

Before publishing, this will ask to login with GitHub. If you are not logged in, just login with your user name and the password.

login

Thus, finally it will add it to GitHub. Message clearly says that it has been added to Remote Repository and you will also view that to click on view link, given below-

Repository

When you visit GitHub profile again, it will show your repository, as follows, with the name "GitHubTestDemo".

GitHubTestDemo

Thus, everything is done on GitHub. If you require anytime from anywhere, you can download it. If you make any changes in the project file which is added to GitHub, click Changes.

changes

It will show all the files, which have made any changes. You can just pass the commit message and click to commit to upload these files into Remote Repository.

changes

You can clearly see that all the published files are locked [Lock sign].

sign
Conclusion

We learned what GitHub is, why to use it and how to publish your local project on GitHub from Visual Studio 2015.

I hope, this post will help you. Please put your feedback, using comments, which helps me to improve myself for the next post. If you have any doubts, please ask your questions in the comment section and If you like this post, please share it with your friends. Thanks.

Up Next
    Ebook Download
    View all
    Learn
    View all