CRAN status License: GPL v3 Codecov test coverage DOI rOpenSci peer-review

R build status

Based on the definition proposed by freecodecamp:

The .gitignore file is a text file that tells Git which files or folders to ignore in a project. A local .gitignore file is usually placed in the root directory of a project. You can also create a global .gitignore file and any entries in that file will be ignored in all of your Git repositories.

For any project, it is therefore important to have a .gitignore file that is complete and accurate. The package gitignore provides a simple R interface to the API. It can be used to fetch gitignore templates that can be included into the .gitignore file of you git repository. The gitignore R package can be used with R package, R Studio project or with any .gitignore file. Note that by default, the usethis package populates the .gitignore for the R language when you create a R project. However, it is common to use many different programming languages in a project such as LaTeX, python, matlab, julia and so one. This is where the gitignore package shines as it can be used to programmatically modify the .gitignore file of your project.


The CRAN version of gitignore can be installed using:


The dev version of gitignore can be installed from GitHub:



There are currently two useful functions in the package:

Show the first 25 templates returned by gi_available_templates().


head(gi_available_templates(), 25)
#>  [1] "1c"                   "1c-bitrix"            "a-frame"             
#>  [4] "actionscript"         "ada"                  "adobe"               
#>  [7] "advancedinstaller"    "adventuregamestudio"  "agda"                
#> [10] "al"                   "alteraquartusii"      "altium"              
#> [13] "amplify"              "android"              "androidstudio"       
#> [16] "angular"              "anjuta"               "ansible"             
#> [19] "apachecordova"        "apachehadoop"         "appbuilder"          
#> [22] "appceleratortitanium" "appcode"              "appcode+all"         
#> [25] "appcode+iml"

Templates can be fetched using the gi_fetch_templates() function.

Multiple templates can be fetched by specifying multiple values:

By default, templates are copied into the clipboard. It is also possible to modify a .gitignore file using the gi_write_gitignore() function.

f <- file.path(tempdir(), ".gitignore")
new_lines <- gi_fetch_templates("r")
gi_write_gitignore(fetched_template = new_lines, gitignore_file = f)

If gitignore_file is not specified, gitignore will try to find the .gitignore file of your current project or package.

More examples are provided in the vignette.


You can also visit the gitignore website.

Code of conduct

Please note that the ‘gitignore’ project is released with a Contributor Code of Conduct. By contributing to this project, you agree to abide by its terms.