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
$ git switch --detach master~1 $ bundle exec jekyll build $ mv _site _site_old
(I’m using the new
`git switch command <https://git-scm.com/docs/git-switch>`__ in place of the classic
I then move back to the new commit and build the site:
$ git switch master $ bundle exec jekyll build
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:
$ git diff --no-index _site_old _site
If your Django project’s long test runs bore you, my book can help.
One summary email a week, no spam, I pinky promise.
Tags: commandline, git, jekyll
© 2020 All rights reserved.