https://github.com/ropensci/gitignore
A R interface to fetch gitignore templates form gitignore.io
https://github.com/ropensci/gitignore
Last synced: 5 months ago
JSON representation
A R interface to fetch gitignore templates form gitignore.io
- Host: GitHub
- URL: https://github.com/ropensci/gitignore
- Owner: ropensci
- License: gpl-3.0
- Created: 2019-05-03T13:24:46.000Z (almost 6 years ago)
- Default Branch: main
- Last Pushed: 2024-11-01T20:45:38.000Z (5 months ago)
- Last Synced: 2024-11-03T12:35:42.937Z (5 months ago)
- Language: R
- Homepage: https://docs.ropensci.org/gitignore
- Size: 1.28 MB
- Stars: 32
- Watchers: 3
- Forks: 5
- Open Issues: 1
-
Metadata Files:
- Readme: README.Rmd
- Changelog: NEWS.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
- Codemeta: codemeta.json
Awesome Lists containing this project
- jimsghstars - ropensci/gitignore - A R interface to fetch gitignore templates form gitignore.io (R)
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# gitignore[](https://cran.r-project.org/package=gitignore)
[](https://www.gnu.org/licenses/gpl-3.0)
[](https://app.codecov.io/gh/ropensci/gitignore?branch=main)
[](https://zenodo.org/badge/latestdoi/184759416)
[](https://github.com/ropensci/software-review/issues/303)
[](https://github.com/ropensci/gitignore/actions/workflows/R-CMD-check.yaml)Based on the definition proposed by [freecodecamp](https://www.freecodecamp.org/news/gitignore-what-is-it-and-how-to-add-to-repo/):
> 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](https://www.toptal.com/developers/gitignore) 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.
## Installation
The CRAN version of `gitignore` can be installed using:
```{r, eval=FALSE}
install.packages("gitignore")
```The dev version of `gitignore` can be installed from GitHub:
```{r, eval=FALSE}
install.packages("devtools")
devtools::install_github("ropensci/gitignore")
```## Examples
There are currently two useful functions in the package:
- `gi_available_templates()` to fetch all supported gitignore templates.
- `gi_fetch_templates()` to fetch one or many gitignore templates.Show the first 25 templates returned by `gi_available_templates()`.
```{r}
library(gitignore)head(gi_available_templates(), 25)
```Templates can be fetched using the `gi_fetch_templates()` function.
```{r, results='markup', comment=""}
gi_fetch_templates("R")
```Multiple templates can be fetched by specifying multiple values:
```{r, results='markup', comment=""}
gi_fetch_templates(c("java", "c++"))
```By default, templates are copied into the clipboard. It is also possible to modify a `.gitignore` file using the `gi_write_gitignore()` function.
```{r, eval=FALSE}
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.
```{r, eval=FALSE}
browseVignettes("gitignore")
```You can also visit the [gitignore website](https://docs.ropensci.org/gitignore/).
## Code of conduct
Please note that the 'gitignore' project is released with a [Contributor Code of Conduct](https://docs.ropensci.org/gitignore/CODE_OF_CONDUCT.html). By [contributing to this project](https://docs.ropensci.org/gitignore/CONTRIBUTING.html), you agree to abide by its terms.
[](https://ropensci.org)