Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

github

r

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?

like image 407
Gorp Avatar asked Jan 16 '20 18:01

Gorp


2 Answers

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.

like image 176
J.P. Le Cavalier Avatar answered Oct 10 '22 22:10

J.P. Le Cavalier


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

like image 33
giocomai Avatar answered Oct 10 '22 21:10

giocomai