2019-09-04 18:31:22 +00:00
---
2021-04-23 15:09:37 +00:00
stage: Create
group: Source Code
2020-11-26 06:09:20 +00:00
info: To determine the technical writer assigned to the Stage/Group associated with this page, see https://about.gitlab.com/handbook/engineering/ux/technical-writing/#assignments
2019-09-04 18:31:22 +00:00
type: reference
---
2021-09-07 09:11:43 +00:00
# .gitignore API **(FREE)**
2019-09-04 18:31:22 +00:00
2020-12-03 09:09:33 +00:00
In GitLab, the `/gitignores` endpoint returns a list of Git `.gitignore` templates. For more information,
see the [Git documentation for `.gitignore` ](https://git-scm.com/docs/gitignore ).
2016-08-08 11:42:24 +00:00
2020-12-03 09:09:33 +00:00
## Get all `.gitignore` templates
2016-08-08 11:42:24 +00:00
2020-12-03 09:09:33 +00:00
Get a list of all `.gitignore` templates:
2016-08-08 11:42:24 +00:00
2019-09-30 06:06:02 +00:00
```plaintext
2016-08-08 11:42:24 +00:00
GET /templates/gitignores
```
2019-09-30 06:06:02 +00:00
Example request:
2020-01-30 15:09:15 +00:00
```shell
2020-12-08 09:09:41 +00:00
curl "https://gitlab.example.com/api/v4/templates/gitignores"
2016-08-08 11:42:24 +00:00
```
Example response:
```json
[
{
2018-10-02 23:00:38 +00:00
"key": "Actionscript",
"name": "Actionscript"
2016-08-08 11:42:24 +00:00
},
{
2018-10-02 23:00:38 +00:00
"key": "Ada",
2016-08-08 11:42:24 +00:00
"name": "Ada"
},
{
2018-10-02 23:00:38 +00:00
"key": "Agda",
"name": "Agda"
2016-08-08 11:42:24 +00:00
},
{
2018-10-02 23:00:38 +00:00
"key": "Android",
2016-08-08 11:42:24 +00:00
"name": "Android"
},
{
2018-10-02 23:00:38 +00:00
"key": "AppEngine",
"name": "AppEngine"
2016-08-08 11:42:24 +00:00
},
{
2018-10-02 23:00:38 +00:00
"key": "AppceleratorTitanium",
"name": "AppceleratorTitanium"
2016-08-08 11:42:24 +00:00
},
{
2018-10-02 23:00:38 +00:00
"key": "ArchLinuxPackages",
2016-08-08 11:42:24 +00:00
"name": "ArchLinuxPackages"
},
{
2018-10-02 23:00:38 +00:00
"key": "Autotools",
2016-08-08 11:42:24 +00:00
"name": "Autotools"
},
{
2018-10-02 23:00:38 +00:00
"key": "C",
"name": "C"
2016-08-08 11:42:24 +00:00
},
{
2018-10-02 23:00:38 +00:00
"key": "C++",
"name": "C++"
2016-08-08 11:42:24 +00:00
},
{
2018-10-02 23:00:38 +00:00
"key": "CFWheels",
2016-08-08 11:42:24 +00:00
"name": "CFWheels"
},
{
2018-10-02 23:00:38 +00:00
"key": "CMake",
2016-08-08 11:42:24 +00:00
"name": "CMake"
},
{
2018-10-02 23:00:38 +00:00
"key": "CUDA",
"name": "CUDA"
2016-08-08 11:42:24 +00:00
},
{
2018-10-02 23:00:38 +00:00
"key": "CakePHP",
"name": "CakePHP"
2016-08-08 11:42:24 +00:00
},
{
2018-10-02 23:00:38 +00:00
"key": "ChefCookbook",
"name": "ChefCookbook"
2016-08-08 11:42:24 +00:00
},
{
2018-10-02 23:00:38 +00:00
"key": "Clojure",
2016-08-08 11:42:24 +00:00
"name": "Clojure"
},
{
2018-10-02 23:00:38 +00:00
"key": "CodeIgniter",
"name": "CodeIgniter"
2016-08-08 11:42:24 +00:00
},
{
2018-10-02 23:00:38 +00:00
"key": "CommonLisp",
"name": "CommonLisp"
2016-08-08 11:42:24 +00:00
},
{
2018-10-02 23:00:38 +00:00
"key": "Composer",
"name": "Composer"
2016-08-08 11:42:24 +00:00
},
{
2018-10-02 23:00:38 +00:00
"key": "Concrete5",
"name": "Concrete5"
2016-08-08 11:42:24 +00:00
}
]
```
2020-12-03 09:09:33 +00:00
## Get a single `.gitignore` template
2016-08-08 11:42:24 +00:00
2020-12-03 09:09:33 +00:00
Get a single `.gitignore` template:
2016-08-08 11:42:24 +00:00
2019-09-30 06:06:02 +00:00
```plaintext
2016-08-08 11:42:24 +00:00
GET /templates/gitignores/:key
```
2019-09-30 06:06:02 +00:00
| Attribute | Type | Required | Description |
| ---------- | ------ | -------- | ------------------------------------ |
2019-02-15 09:39:23 +00:00
| `key` | string | yes | The key of the `.gitignore` template |
2016-08-08 11:42:24 +00:00
2019-09-30 06:06:02 +00:00
Example request:
2020-01-30 15:09:15 +00:00
```shell
2020-12-08 09:09:41 +00:00
curl "https://gitlab.example.com/api/v4/templates/gitignores/Ruby"
2016-08-08 11:42:24 +00:00
```
Example response:
```json
{
"name": "Ruby",
"content": "*.gem\n*.rbc\n/.config\n/coverage/\n/InstalledFiles\n/pkg/\n/spec/reports/\n/spec/examples.txt\n/test/tmp/\n/test/version_tmp/\n/tmp/\n\n# Used by dotenv library to load environment variables.\n# .env\n\n## Specific to RubyMotion:\n.dat*\n.repl_history\nbuild/\n*.bridgesupport\nbuild-iPhoneOS/\nbuild-iPhoneSimulator/\n\n## Specific to RubyMotion (use of CocoaPods):\n#\n# We recommend against adding the Pods directory to your .gitignore. However\n# you should judge for yourself, the pros and cons are mentioned at:\n# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control\n#\n# vendor/Pods/\n\n## Documentation cache and generated files:\n/.yardoc/\n/_yardoc/\n/doc/\n/rdoc/\n\n## Environment normalization:\n/.bundle/\n/vendor/bundle\n/lib/bundler/man/\n\n# for a library or gem, you might want to ignore these files since the code is\n# intended to run in multiple environments; otherwise, check them in:\n# Gemfile.lock\n# .ruby-version\n# .ruby-gemset\n\n# unless supporting rvm < 1.11.0 or doing something fancy , ignore this: \n. rvmrc \n"
}
```
2019-09-04 18:31:22 +00:00
<!-- ## Troubleshooting
Include any troubleshooting steps that you can foresee. If you know beforehand what issues
one might have when setting this up, or when something is changed, or on upgrading, it's
important to describe those, too. Think of things that may go wrong and include them here.
This is important to minimize requests for support, and to avoid doc comments with
questions that you know someone might ask.
Each scenario can be a third-level heading, e.g. `### Getting error message X` .
If you have none to add when creating a doc, leave this section in place
but commented out to help encourage others to add to it in the future. -->