I am using RStudio, where I have both a README.Rmd and a README.md file. However, when I have only changed in the README.Rmd and want to commit and push it to GIT I get this:
RStudio README.Rmd and README.md should be both staged use 'git commit --no-verify' to override this check
Where should I add: "git commit --no-verify"?
And/or how can I avoid this message?
When you're editing your README.Rmd
file, your README.md
file is not automatically synchronized. Since GitHub will display your README.md
(and not your README.Rmd
file), there is a check that you have build your README.md
file before pushing it to GitHub. Not doing so would prevent any change that you made in the README.Rmd
file to appear on your repository.
I would suggest to always use the following workflow :
README.Rmd
fileREADME.md
file by running devtools::build_readme()
in the R consoleREADME.Rmd
and README.md
Doing this should not throw any warning and everything will work the way you probably want.
People who bump into this question may want to check out the debate in the relevant issue of the usethis
package.
In brief, this is caused by using usethis::use_readme_rmd()
, which sets up a pre-commit hook in .git/hooks/pre-commit
. This hook ensures that readme.Rmd
and readme.md
are updated at the same time. If only one changes, then the error message included in the title of this question appears.
This is likely to be annoying if, for example, your readme includes some summary statistics that can be rebuilt as the project updates or some random data.
The temporary solution is to do as the message says, i.e. go to terminal and type:
git commit --no-verify -m "my commit message"
If you want to get rid of this behaviour altogether, you should delete the .git/hooks/pre-commit
file.
From the R console, you can achieve this with:
file.remove(".git/hooks/pre-commit")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With