Connect your Visual Studio project to GitHub

In this post I want to share with you guys short tutorial how to upload your code from Visual Studio to GitHub using Git and Team Explorer.

I must admit, that I haven’t been familiar with Version Control until I start work and that was no long ago so I am still learning about It and my knowledge is not huge yet.

I was allways interested in how It is possible to develop project by many people. How It is possible to work on the same code at the same time.
And you know what? That is really simple and not hard to understood.

How It works

Imagine that we have two dudes working on the same project. One guy working on his area in project and another one working in the other area. let’s assume that they are using a one mutual class which name is: „HereAreTroubles”.
First guy add some code to our „HereAreTroubles” class and committed It. Another guy also finished work for today, He made one task and want to commit his job before he goes to home. He knows that before commit It is necessery to update our code. And.. here we are. After updating he saw that System Version Control like SVN or Git tells him taht there are some conflicts. And what exactly does It mean? In our case It means that in „HereAreTroubles” class He and his team mate changed some code. For example They could delete, or add new lines.
System Version Control show the changes and mark where is the problem. Now He must indicate what SVC have to do. There are several options like: use my code before theirs or use my code or use therir code etc.
And that’s It, now after resolve problems He can commit his job and go to home.

I hope that now you know the goal of using Version Control. I want to add that there is a lot of other options like we can check who made changes and we can compare earlier versions etc.

Connect Visual Studio with Github

For Daj się poznać competition I must learn how to use GitHub, how to upload my code there and how commit my changes.

For begin I want to admit that It is really simple and I think works well! You must know that I am not expert but I spend some hours to learn It and want to share my knowledge with you guys.

1. Create repository – firstly You have to create account on GitHub and create new repository. If you check Initialize this repository with a README It will makes automatically master branch for You, so I don’t use It for my case.
Of course You might check It but after It in Visual Studio You won’t be able to publish your brach as master. You will have to name It in other way.

creating github repo

2. Second step is to create your local repository. And You have to do this adding the Local Git Repository in Team Explorer In Visual Studio.

create local git repo

3. Now You have your local Git Repository and You need to add new project to It. Click twice your created repository and select New button. Now You have to choose your kind of project I just create Console Application. Don’t forget to check box: Add to source control. Click OK. Now You should see that you have files in Your folder for local repository.

add new project to repo

4. Commit your project – click right button on your soluction name -> SourceControl -> Commit. In new window You have to type message describing that commit for example what changed and again click Commit

first commit

5. Now You have to Sync your commit to share your changes with the server. If You first time syncing You need to configure URL for your GitHub repository (just copy from browser) and You will have to sign in to GitHub from Visual Studio. I am not doing this because I am already signed. Choose from home window of Team explorer Unsynced Commits and  enter your repository URL and publish It. Now sync button is avaiable and You can use It.

publish to remote repository
That It’s. It’s just that simple 🙂 Now You can log in to your GitHub account and You will see your project online. After any next changes in your solution You can commit It to GitHub to any branch You want.

Reklamy

Skomentuj

Wprowadź swoje dane lub kliknij jedną z tych ikon, aby się zalogować:

Logo WordPress.com

Komentujesz korzystając z konta WordPress.com. Wyloguj / Zmień )

Zdjęcie z Twittera

Komentujesz korzystając z konta Twitter. Wyloguj / Zmień )

Zdjęcie na Facebooku

Komentujesz korzystając z konta Facebook. Wyloguj / Zmień )

Zdjęcie na Google+

Komentujesz korzystając z konta Google+. Wyloguj / Zmień )

Connecting to %s