githubvisualstudio
0

Connect GitHub and Visual Studio

A very simple but, at the same time, very useful post, for all the people who like to work in .NET and keep uploading their code to GitHub.

I don’t think it’s necessary to name all the advantages that GitHub offers to us as developers. Is a powerful and well known tool in our profession, but maybe, its use is less extended between the .NET specialists. That’s why  I wanted to create one of the first posts of this blog dedicated to connect GitHub and Visual Studio.

Let’s get to work. The first thing we’ll need is Visual Studio 2015, so, if you are still using an older version, you have another reason to upgrade. The second component we will need is the GitHub Extension, which you can download for free from the official website or install it directly from the Extensions Manager.

githubextensionlist

Once we have it installed, in the Team Explorer window, we will see GitHub as a service provider. Clicking on “Connect” will open a window to log in with your GitHub credentials. We can use a free account or an Enterprise one.

At this point, Visual Studio is linked with our GitHub account, so the next step should be to clone one of our repositories in our local hard drive. I have selected my “hello-world” repository for this tutorial, which I will download in my Visual Studio Projects folder:

clonerepository

Now, we can see the selected repository in our Local Git Repositories list. Right clicking in it and selecting “Open”, we will access to the content inside the repository.

We are ready to add code to our repository. If it doesn’t contain any solution, we will see it empty, so we can click on “New” and create a simple solution, just to test that everything is working properly. I have just created an empty WebForms application, unchecking the “Create new Git repository” checkbox, because I want to create the solution inside the hello-world repository.

hello-worldsln

Great, we already have a solution created in our local clone of our GitHub repository. It’s time to move forward and upload our code. Don’t look for the “Checkin” option, unfortunately, in version 2.0.15, there isn’t that option, but there ather other ways to “checkin” our changes. The option I rather to use is click on the “Changes” option, which allows me to view all the files that had been changed and ignore the ones that I don’t want to upload. Now we just write a comment and confirm the changes.

confirmarcambios

Finally, once we have our changes confirmed, we will see a message allowing us to sincronize with our GitHub repository. This is the slow way to do this, but I like it, because it allows me to see all the in and out confirmations, extract, insert or sincronize all the repository. If you want to go faster, you can skip this step, displaying the “Confirm and sincronize” option in the “Changes” window.

If everything was ok (lucky you), we will see a message which indicates the sincronization was done properly. Is time to open our repository in the GitHub website and check that everything is fine.

hello-world-commited

We now have every necessary thing to work with our GitHub code from Visual Studio. I know it is a pretty basic tutorial and most of you would want a lot more to go further and take advantage of all GitHub features. I promise to go deeper in next posts, with more advanced options like create Pull Requests and merge different branches.

Leave a Reply

Your email address will not be published. Required fields are marked *