.gitignore for R

20 ignore rules for R, ready to copy into your repository.

Language for statistical computing

The complete .gitignore for R

# Generated by LFGitignore - https://lfgitignore.com
# Created: 2026-01-15 09:46:12 UTC
# Technologies: R

### R ###
.Rhistory
.Rapp.history
.RData
.RDataTmp
.Ruserdata
*-Ex.R
/*.tar.gz
/*.Rcheck/
.Rproj.user/
vignettes/*.html
vignettes/*.pdf
.httr-oauth
*_cache/
/cache/
*.utf8.md
*.knit.md
.Renviron
docs/
po/*~
rsconnect/

What these R rules actually ignore

Every pattern below, and why it belongs in your .gitignore.

History files

Pattern What it ignores
.Rhistory History files
.Rapp.history History files

Session Data files

Pattern What it ignores
.RData Session Data files
.RDataTmp Session Data files

User-specific files

Pattern What it ignores
.Ruserdata User-specific files

Example code in package build process

Pattern What it ignores
*-Ex.R Example code in package build process

Output files from R CMD build

Pattern What it ignores
/*.tar.gz Output files from R CMD build

Output files from R CMD check

Pattern What it ignores
/*.Rcheck/ Output files from R CMD check

RStudio files

Pattern What it ignores
.Rproj.user/ RStudio files
vignettes/*.html produced vignettes
vignettes/*.pdf RStudio files

OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3

Pattern What it ignores
.httr-oauth OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3
*_cache/ knitr and R markdown default cache directories
/cache/ OAuth2 token, see https://github.com/hadley/httr/releases/tag/v0.3

Temporary files created by R markdown

Pattern What it ignores
*.utf8.md Temporary files created by R markdown
*.knit.md Temporary files created by R markdown

R Environment Variables

Pattern What it ignores
.Renviron R Environment Variables
docs/ pkgdown site
po/*~ translation temp files

RStudio Connect folder

Pattern What it ignores
rsconnect/ RStudio Connect folder

How to use this .gitignore for R

  1. Copy the R rules above, or download the file directly.
  2. Create a file named .gitignore at the root of your Git repository and paste the rules into it.
  3. If some of those files are already tracked, run git rm -r --cached . then commit again — Git only applies ignore rules to untracked files.
  4. Commit the .gitignore so everyone on the team shares the same rules.

Other Language .gitignore templates

See every Language template