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 of Pieter Veenstra

Is your business still running on paper trails, sprawling Excel files, or ageing Access databases? There's a better way — and I can show you exactly what it looks like. I'm the Technical Director of Vantage 365, a Microsoft solutions consultancy working with clients across the UK, the Netherlands, and worldwide. For over 30 years I've been turning messy, manual business processes into clean, automated systems that save time, reduce errors, and give teams the visibility they need to make better decisions. SharePains is not just any blog run by a Microsoft MVP. Have you ever used Try-Catch in Power Automate? The original post about Try-Catch in Power Automate can still be found on this site, https://sharepains.com/2018/02/07/try-catch-finally-in-power-automate-flow/ Or have you ever used the Pieter’s method to avoid variables and speed up your flows? https://sharepains.com/2020/03/11/pieters-method-for-advanced-in-flows/ You can contact me using contact@sharepains.com

Related Posts

Leave a Reply

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

Discover more from SharePains

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

Continue reading