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

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

Get Started with MongoDB Stitch : The New Backend As Service Offering from MongoDB

Halfway of this year, the guys from MongoDB launch their new backend as service product called MongoDB Stitch. While the launch is just for the beta, the promise of the service is quite interesting. MongoDB has been around for long now and some development stacks have been based on its database product, the MongoDB-ExpressJS-Angular-NodeJS (MEAN) and the MongoDB-ExpressJS-React-NodeJS (MERN) stacks to name a few. These stacks, however, relies on backend technology such as ExpressJS and NodeJS. The idea of provisioning servers and developing the backend solution makes it daunting for small to medium scale applications. MongoDB Atlas, at least made life much easier by providing on cloud database solution, but there must be a simpler solution, right? A solution the would stitch the backend and frontend together ( see what I did there ?).
MongoDB Stitch lets developers focus on building applications rather than on managing data manipulation code, service integration, or backend infrastruct…

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

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 internet for a better solution. I stumbled upon Stateless