Comparing Generated Files Before and After Changes with Git Diff2020-01-29
Once in a while, I have to make a change to many or all of my blog posts. For example, implementing opengraph meta tags.
After I’ve made the change, I want to verify that all the generated HTML changed in only the way I expected. I do this by reading, or at least skimming, the diff of before versus after.
Say I’ve just made the change on my git respository’s master in a single commit.
I’ll first rewind to the previous commit, build the site, and move it to a different name.
I use Jekyll, which by default builds all HTML in a
(I’m using the new
git switch command in place of the classic
I then move back to the new commit and build the site:
I then compare the diff of the two.
Rather than using the vanilla
diff command, I use
This option allows use of
git diff on uncommitted files and folders.
git diff is better than vanilla
diff since it colourizes its output and uses the pager command by default:
I hope this helps you verify your changes,
Working on a Django project? Check out my book Speed Up Your Django Tests which covers loads of best practices so you can write faster, more accurate tests.
One summary email a week, no spam, I pinky promise.
© 2020 All rights reserved.