SharePoint – PnP – Github – This branch is 245 commits behind SharePoint:master.

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. 1

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. 2

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. 3

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. 4

the git remote -v will now show:

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

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. 6

Now I’ll need to merge the code.

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

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. 8

Now my branch is even with the PnP master branch.

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

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. 10

 

 

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. 11

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

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

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

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

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

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

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

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

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. 17

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. 18

Time to find that option in Visual Studio

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

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. 20

I confirm the branches:

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

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

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

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

 

Leave a Reply

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

%d bloggers like this: