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

renaming default namespaces for VSTO projects in VS2008

So here is the scenario , you are starting a VSTO project and decided that your default namespace is ExcelAddInTesterApp . You created the project and started coding the project. After several days , your boss called and said "hey marvin , make use of this namespace OurCompany.ExcelAddInTesterApp , we have to add our company name to it got it?" . You get back to your machine thinking its just a simple property just like any project you've been working on. So you right clicked the VSTO project and hit properties . Boom! What the F@#$? The default namespace textbox is disabled!!!!



I've been through this and I googled for ways to do it and ended up with a blog from a Microsoft MVP telling me it can't be done because it is disabled. Then I thought of Refactoring, the beauty and grandeur of the renaming process. I selected the namespace and hit the refactor menu hoping that this would solve the problem . Unfortunately , it did not rather it displayed the message box …

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

this year

.. i will learn new things, perhaps play a new instrument or go back to school.
.. i will find beauty on the open source community.
.. i will read more books and listen to more music.
.. i will pen more poems and possibly write more songs.
.. i will go for new distances and discover new terrains.
.. i will continue to pile running miles to stay fit and healthy.
.. i will strive to be free and make myself available to unknown future.
.. i will go out of my shell more often and be socially more open.

.. i will continue to grow and go with the changes of time.
.. i will be more patient and hopeful to things that may not even be possible.
.. i will be a better son, brother and more importantly a better father.
.. i will be closer with the great beyond.

.. i will continue to repair , refactor and upgrade myself to become a better version of me.