Want to share your content on R-bloggers? click here if you have a blog, or here if you don't.

When writing an R package I usually write a README.Rmd file that I render to README.md. I use {pkgdown} to then create documentation. I run the last step via CI, so I never need to think about it.

The problem is that I regularly forget to process the README.Rmd file, which means that despite keeping that it to date, everything else lags behind.

What if I automated the process? I created a simple pre-commit hook which processes README.Rmd whenever I make a commit and automatically adds any changes to the commit.

To do this is simple: just create a file called pre-commit in the .git/hooks folder with the following content:

#!/bin/sh

then
fi
Make it executable and… Voila! 🚀 Whenever you commit, the README.md file will be updated if it’s older than the most recent change to README.Rmd.