Recently, I received notification from Planet PowerShell that they will be removing blogs that do not support HTTPS as of August 1st. I had forked their repo on GitHub over a year ago, added my blog, and submitted a pull request. I hadn’t touched my fork of their repo since then. It was severely out of date and in an unknown state.
Taking a look at it on my system showed my local copy only had one remote which was my fork on GitHub.
git remote show
git remote show origin
I could see that one of the files had been updated in my local copy, but not committed. I didn’t have a clue about what changes had been made or why they were made.
The git diff command can be used to show what’s been changed as shown in the following example.
git diff src/Firehose.Web/Authors/MikeRobbins.cs
I don’t care about those changes. I’ll simply check that file out again to discard those changes.
git checkout src/Firehose.Web/Authors/MikeRobbins.cs
Now I’ll add the upstream remote and fetch any updates, or a copy of it in this scenario.
git remote add upstream https://github.com/planetpowershell/planetpowershell.git
git fetch upstream
All that needs to be done now is to merge the changes from upstream into my current branch.
git merge upstream/master
I know why they call this a GitHub fork. Stick a fork in it, this repo is done!
That was wishful thinking. While the previous command would work in many cases, this repo is too far out of date. I could simply delete my local copy and my forked copy of it on GitHub and then fork it again along with cloning it locally again. That’s a lot of trouble and work. I’ll simple do a hard reset on my local copy and then force those changes into my forked copy on GitHub.
Warning: Use the following commands at your own risk!
Per the Git documentation, the following command “Resets the index and working tree. Any changes to tracked files in the working tree are discarded”. You will loose any changes you’ve made using these commands.
Make sure you understand what is happening before proceeding.
git reset --hard upstream/master
git push --force
My local copy and my forked copy on GitHub are now in sync with the Planet PowerShell repo on GitHub.
git remote show origin
git remote show upstream
Now I can make the necessary changes to my profile file to direct readers on Planet PowerShell to my blog site via HTTPS instead of HTTP and everyone will be happy!