RStudio adds .gitignore file to top of directory when opening Rproj

We are working in a repository that combines R, web and database code:

  • db
  • web
  • r
    -- r_package1
    -- r_package2

Whenever we open a .Rproj (for example, r_package1.Rproj) a .gitignore file is added to the root of the directory.

Can this be switched off?

RStudio creates this .gitignore file to ensure that its own state-related folder (.Rproj.user) is not accidentally added to the Git repository. Is there a reason why you want to suppress its creation?

2 Likes

We have a .gitignore in the 'r' folder shown above.

However, whenever we open a lower level project, another .gitignore is added at the root (alongside the db, web and r folders)

I can work around it if necessary