So I’ve setup repositories for PnP projects. As a real PnP Enthusiast I’ve clones all the PnP 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:
Now I’m seeing in my forks messages : “This branch is X commits behind SharePoint:master
How can I make all my branches to pick up the latest version of the code?
the git remote -v will now show:
Now I’m going to fetch the latest code from the PnPMaster branch with git fetch PnPMaster
Now I’ll need to merge the code.
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.
Now my branch is even with the PnP master branch.
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.
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
In the Add remote I add the url for the PnP PowerShell branch
and when I now look in my branches, I’m seeing …
Hmm, there not there yet. even though my settings report:
Ok, so the interface isn’t perfect yet as my git bash is whoing the expected result.
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:
Time to find that option in Visual Studio
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:
I confirm the branches:
and my merge will complete and my repositories are nicely in sync again.
At last I can now retire git bash…. at least for now.