Skip to main content

Integrating GitHub on Visual Studio 2017 : Your First Repo, Commit, Push, and Pull

Lets get started publishing our VS2017 code to GitHub. If  your IDE is not yet configured to use GitHub, read this article as a starter. There are two ways to start contributing to the open source community via GitHub : clone or fork  an existing repository and start contributing and publish a new repo on GitHub.

Creating a New Repository in GitHub

Create a new blank solution.  Make sure the Create New Git Repository option is checked.Once created, this will only reside on your local machine until we publish it online.  Go ahead and add a simple console app and test before start committing.  Note that VS2017 will automatically add a .gitignore file for the project.
 
The Team Explorer pane should be displaying the new repo on the Local Repositories section. Double click on the repo to access the available actions.
 
  • Changes - Use this to view code changes you have made in the project.
  • Sync - Use these to initiate syncing between repositories. Such as fetching, pulling or pushing changes to GitHub.
  • Branches - Let you manage the branches in your repo.
  • Settings - Let you manage global and repository settings.
Lets view the changes on the repo. The pane will display all new files added to the project but is not yet part of the repo. The UI also allows us to commit these changes right away.
There are three options provided when committing changes : Commit All, Commit All and Push and Commit All and Sync. 
 
  1. Commit will simply make record of your changes that you have made on your local machine. It will not mark the change in the remote repository.
  2. Commit and Push will do the above and push it to the remote repository. This means that any changes you have made will be saved to the remote repository as well.
  3. Commit and Sync does three things. First, it will commit. Second, it will perform a pull (grabs the updated information from the remote repo). Finally, it will push. 
 
A discussion on StackOverflow regarding this can be found on this link.
 
For this tutorial, lets do simple Commit All. To publish the repo to GitHub, click on the Sync option and select Publish to GitHub. You may need to enter your credentials.
 
 
 
 
Once the repo is published, the Home page on the Team Explorer pane will be updated to display the link to the online repo and new available actions. 
Your GitHub page will now include your new repo. By default, this is a public repo, thus, anyone can fork or clone it.
 

Pushing your changes to GitHub

The first section discussed the initial phase of the process. Now that the repo is available online, we can continue adding functionality to our app and push changes to GitHub as needed. For this section, we assume that no other changes on the online repo and we are pushing our fist update. Go ahead and make some changes to our app. You should notice that the IDE marks those changes on the source code view as well as on the files view. The Changes view will display those changes and for this time we can do Commit All and Push. Once Push is completed, the update will be reflected on GitHub.
 

Pulling changes from GitHub 

For simple changes without any conflicts, a Sync operation will do the trick on the Synchronization page. But for clarity, we will do a Fetch and a Pull to show the changes.
 
Fetch operation updates only your remote-tracking branches. It does not update the codes you are working on. A pull operation is a Fetch followed by Merge action. This will automatically bring your codes up to date with the remote branch. For this sample, we do Fetch first to show the changes. The Synchronization page will display incoming commits from the remote repo.
To view the changes related to the incoming commit , right click the commit entry and select View Commit Details.
 
Once everything is ok, you can select Pull action to update your working code.
 
This tutorial discussed simple git operations. This may not be enough once the project get big and a number of developers is added.
 
 
 
 
 

Comments

Popular posts from this blog

Getting Started with Stateless : A Lightweight Workflow Library Alternative for .NET

Image Credit: https://www.pioneerrx.com A year ago, I was looking for a simple workflow manager for a project I was working. Its a medium sized application that involves tracking the state of assets in the system. Back in 2008, Microsoft (MS) introduced new technologies along with the release of Visual Studio 2008: Windows Presentation Foundation (WPF), Windows Communication Foundation (WCF), and  Windows Workflow Foundation (WF). Having worked in a company utilizing mostly MS products for development, my first option was to go with WF. After doing some time reading and studying the library, I paused and decided it was too complex for my requirement. Using WF would be an overkill and the fact that it has, a rather, steep learning curve, there has to be another option. My mind toyed with the idea of developing a simple workflow library myself. It would be a learning experience but it might end up consuming a lot of time. Why reinvent the wheel? So I started querying the ...

Hiding Unwanted Python Folders and Files in Visual Studio Code

Visual Studio Code is a universal editor and pretty good at it. However, the explorer view maybe cluttered with the automatically generated folders and files confusing developers. Python is no different. Below are example files and folders generated by Python. The __pycache__ folder and *.pyc files  are totally unnecessary to the developer. To hide these files from the explorer view, we need to edit the settings.json for VSCode. Add the folder and the files as shown below: Copy and paste the lines below : "**/*.pyc" : { "when" : "$(basename).py" }, "**/__pycache__" : true

Cyber-bullying : The "good", the bad and the ugly

Image courtesy of http://www.digitalesq.com/ Cyber-bullying is defined as  the willful and repeated use of cell phones, computers, and other electronic communication devices to harass and threaten others. With the advent of social media, the incidents has increased in numbers and the victims does not even know what is hitting them. For the past years, we have heard of  depressions and deaths because of this. Yet, there has never been a strong drive to increase public awareness and promote support groups to help victims outside of the schools.  Campaigns and programs has never gained mainstream presence enough to make an impact.