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:
As these projects are updated frequently I’m creating multiple repositories. on my local machine.
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?
For each project you can create a personal copy of the code. simply by clicking on the Fork button:
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
- git remote add schemaMaster https://github.com/OfficeDev/PnP-Provisioning-Schema
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.