Updating my blog theme with git
In this short post, I’ll show how I update my static website hosted on github using git.
I moved my blog from Google Blogger to Github Pages and Jekyll about 2 years ago.
- I found a Jekyll theme that I liked,
- forked the repository,
- rename the repository to
<github username>.github.io
- Blog up and running! 🚀
- You can now clone your fork locally and start writting blog posts.
The migration of my old blog posts and comment was another story 😶.
Starting a blog from an existing theme
We can summarize the workflow described above like this:
- Fork a repository (blog theme source)
- Clone your fork locally
- Create custom content locally and commit back to your fork
- Static website gets regenerated each time you commit to your fork
Blog theme update
However, when the Blog theme author release a new version, how to you pull the latest changes ?
One of the great advantage of having my blog content hosted on git is that I can easily use git to pull the last updates from the jekyll theme used.
In my case I’m using the Minimal Mistakes Jekyll theme from mmistakes. You’ll need to adapt the following code for the theme that you are using.
- List your remote repositories: You must first ensure there’s an upstream remote. If you forked the theme’s repo then you’re likely good to go.
- To double check, run
git remote -v
and verify that you can fetch from originhttps://github.com/mmistakes/minimal-mistakes.git
- To double check, run
- Add your remote repositories (optional): To add it manually you can do the following:
git remote add upstream https://github.com/mmistakes/minimal-mistakes.git
- Pull the changes:
git pull upstream master
- Depending on the amount of customizations you’ve made after forking, there’s likely to be merge conflicts. Work through any conflicting files Git flags, staging the changes you wish to keep, and then commit them. You can also do these steps using Microsoft Visual Studio Code (see below).
- Push the change to your fork:
git push
Conflicts
When pulling the changes from the Upstream (as see above) you might see some conflicts, example during my last upgrade:
You resolved these issues using Visual Studio, here is an example:
Leave a comment