How to do it...

  1. Adding the GitHub extension to Visual Studio is easily done by downloading the visx from the following link and installing it: https://visualstudio.github.com/downloads/GitHub.VisualStudio.vsix.
  1. Assuming that you have an existing application you want to add to GitHub, the process of adding it to a new repository is quite simple. I have simply created a console application with nothing but the template code, but you can add any project type and size to GitHub.
  1. On the View menu in Visual Studio 2017, select the Team Explorer option.
  1. You will be presented with two options under the Hosted Service Providers section. For now, we will select GitHub and, seeing as we already have an account, we will click on Connect...
  1. You will now be presented with the GitHub login page. You are also offered the chance to sign up from here if you do not have an existing GitHub account:
  1. Because I have Two-factor authentication set up on my GitHub account, I am prompted to use my authenticator application to enter the generated authentication code and authenticate myself:
  1. After you have been authenticated, you will return to the Manage Connections screen. If your project isn't displayed under the Local Git Repositories, you can add it:
  1. Next, you will want to click on the Home icon, which is a picture of a little house at the top of the Team Explorer window. From the Home screen, click on the Sync button:
  1. This will display the Publish window to you. Under GitHub, click on the Publish to GitHub button. This is going to publish your project to a new repository on GitHub.
Remember, if you are using the free GitHub, all your repositories are public. If you are writing code that can't be made public (is not open source), then sign up for one of the paid GitHub accounts that include private repositories.
  1. GitHub will then prompt you to add in the details for this publish. Because you connected to GitHub earlier, your username will already be selected in the drop-down menu. When you are ready, click on Publish:
  1. When the project has been published to GitHub, you will automatically be returned to the Home screen:
  1. Looking at your GitHub account online, you will see that the project has been added:
  1. Next, let's go and make some changes to the GitHubDemo application. Just go ahead and add a new class to your project. I called mine NewClass.cs, but you can call yours whatever you like.
  1. You will notice that as soon as a change is made to your project, that the solution will mark the changed items with a red tick. Your class is marked with a green plus sign:
  1. To add the changes to your GitHub repository, you can follow two routes. The first option is to go to the Team Explorer - Home window and click on the Changes button.
  1. The second (and in my opinion more convenient) option, is to right-click the solution in Solution Explorer and click on the Commit... menu item from the context menu.
  1. GitHub might ask you for your user information the first time you perform a commit.
  1. Before you are allowed to commit your changes, you must fill in the required commit message. In a real team project, be as descriptive as possible in your commit message. Consider using task item code (or backlog codes) to uniquely identify the code being added. This will save your (or another developer's) bacon sometime in the future, I guarantee it:
  1. One important thing to note is that you have three commit options available to you if you click on the down arrow next to the Commit All button. The Commit All button will just record the changes you make on your local machine. In other words, the change will not be reflected in the remote repository. The Commit All and Push button will record the changes on your local machine and push those changes to your remote GitHub repository. The Commit All and Sync button will record the changes on your local machine, then it will pull any changes from the remote repository, and finally it will do the push. You will want to do this if you are working in a team. For this recipe, however, I will just do a Commit All and Push, seeing as I am the only developer working on this repo:
  1. When the commit has completed, the Team Explorer - Synchronization window will notify you of the successful commit:
  1. Heading over to GitHub online, you will see the newly pushed changes reflected in your GitHub repository, along with the commit message:
  1. GitHub is a fantastic source control solution for any developer. Consider creating an open source project. It is more beneficial than you might imagine.
More and more these days, prospective employers are reviewing developers' GitHub repos when considering applicants for developer positions. Keep that in mind, because a GitHub repo is a resume in itself.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.140.204