Oscar Kjell
Oscar Kjell

Reputation: 1651

RStudio README.Rmd and README.md should be both staged use 'git commit --no-verify' to override this check

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?

Upvotes: 12

Views: 3476

Answers (2)

giocomai
giocomai

Reputation: 3528

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")

Upvotes: 14

J.P. Le Cavalier
J.P. Le Cavalier

Reputation: 1345

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 :

  1. Edit your README.Rmd file
  2. Build your README.md file by running devtools::build_readme() in the R console
  3. Commit both your README.Rmd and README.md

Doing this should not throw any warning and everything will work the way you probably want.

Upvotes: 7

Related Questions