I’ve been using GitHub now for a while for  a number of projects. The OfficeDev/PnP is quite well organised however it is not always clear how to use GitHub. On a regular basis people contributing to the project submit changes to the master branch.

I’ve also found synchronizing code, updating my personal fork and some more of these basic tasks quite difficult. Google/Bing is helpful but it is always a struggle to find what I’m looking for.

Some background on PnP

I’m using the PnP project as a base for this article. There are multiple projects that I’m going to look at. The root projects are located at:

https://github.com/OfficeDev/PnP-Provisioning-Schema

https://github.com/OfficeDev/PnP-Sites-Core

https://github.com/OfficeDev/PnP-PowerShell

As these projects are updated frequently I’m creating multiple repositories. on my local machine.

  • C:\Git
  • C:\GitMaster

C:\Gitmaster contains a copy of the above GitHub projects. I use this repository whenever I want to switch back to the latest released version.

C:\Git contains a copy of my personal fork. Fork??? What’s that?

Github Fork

For each project you can create a personal copy of the code. simply by clicking on the Fork button:

Fork

Note that this fork is a current copy of the code and this doesn’t get updated without some work described on the GitHub help pages. So the first time you create a fork the code is synchronised after that you’ll have to got through the steps.

Updating the code in a fork

  • Open Git Bash.
  • cd c:\git\PnP-Provisioning-Schema
  • git remote -v

This command gives me the end points. In my case I created schemaMaster as an endpoint

if you’ve already done that already then simply use the endpoint name that already exists:

  • git fetch schemaMaster
  • git checkout master
  • git merge schemaMaster/master

this now updates the code in your local copy of the master branch code. Repeat the last two steps for the dev as well if you want to switch between dev and master.

Now that this is done Visual Studio may need to reload the project.

Now within Visual Studio I’m running a Sync so that the updates added to my local copy of the code are now added to my fork. My fork is updated with the latest changes of the master.

Note that a lot of the options are now available within Visual Studio, however using the command line makes it clearer when things go wrong.

 

 

 

 

 

 

Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading