So I’ve setup repositories for PnP projects. As a real PnP Enthusiast I’ve clones all the PnP repositories.

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint repositories

For each branch I’ve cloned my own fork. Git bash will show me my the locations where I’ve cloned each repository from:

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint cloned

Now I’m seeing in my forks messages : “This branch is X commits behind SharePoint:master

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint this branch is behind

How can I make all my branches to pick up the latest version of the code?

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint add branch

the git remote -v will now show:

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint newbranch

Now I’m going to fetch the latest code from the PnPMaster branch with git fetch PnPMaster

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint fetch

Now I’ll need to merge the code.

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint merge

So now my local code matches the PnP master. One more step to go for, I need to push the updates that I just received to my github fork.

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint push

Now my branch is even with the PnP master branch.

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint even

I can also do the the same for the dev branch. As the PnP team only accepts changes in the dev branch it’s probably worth it only to do the above steps in the dev branch.

In short a lot of steps to go through.

Yes we could create a script/batch file to do this all on a regular basis but still it’s a pain to go through this all.

With the latest version of Visual Studio and with the Github for Visual Studio extensions things become a lot easier.

 

Again I have already cloned my repository and I want to bring them into sync with the PnP master branches.

I’m first doing the equivalent of  a git remote -v and I’m looking at my branches.

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint tebranches

 

 

time to find git remote add PnPMaster https://github.com/SharePoint/PnP-PowerShell.git

This option is really hidden away in Settings -> Repository Settings -> Remotes -> Add

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint settings

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint reposettings

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint addremotes

In the Add remote I add the url for the PnP PowerShell branch

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint addremote

and when I now look in my branches, I’m seeing …

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint tebranches

Hmm, there not there yet. even though my settings report:

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint settingsremote

Ok, so the interface isn’t perfect yet as my git bash is showing the expected result.

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint remotev

I’ve closed the project and reopened it but still no luck. I even restarted Visual Studio but still no change.

So I started again running the commands from the git bash window and I noticed that as soon as I ran git fetch PnPMaster my PnPMaster remote would appear in visual studio:

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint fetchmaster

Time to find that option in Visual Studio

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint fetchpnp

Ok, now I’m getting somewhere. I can now synchronize my branches with the master branches form the PnP team using just Visual Studio.

Back to the steps I used to follow in git bash it is now time to do a git merge PnPMaster/master (or dev branch of course)

The Merge Form option is the on that does the trick:

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint mergeform

I confirm the branches:

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint mergefromdetails

and my merge will complete and my repositories are nicely in sync again.

SharePoint - PnP - Github - This branch is 245 commits behind SharePoint:master. Microsoft SharePoint even

At last I can now retire git bash…. at least for now.

 

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