DOI

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 gitignore.io 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 be 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.

Installation

The CRAN version of gitignore can be installed using:

install.packages("gitignore")

The dev version of gitignore can be installed from GitHub:

install.packages("devtools")
devtools::install_github("ropensci/gitignore")

Examples

There are currently two useful functions in the package:

Show the first 25 templates returned by gi_available_templates().

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 <- paste0(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.

browseVignettes("gitignore")

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.

ropensci_footer