The REST API is now versioned. For more information, see "About API versioning".
Gitignore
Gitignore API では、ファイルやディレクトリを無視するために利用できる .gitignore テンプレートをフェッチします。
Gitignore API について
この API を使って GitHub.com に新しいリポジトリを作成する場合、作成時にリポジトリに適用する .gitignore テンプレートを指定できます。 .gitignore テンプレート API では、GitHub .gitignore リポジトリからテンプレートを列挙およびフェッチします。
gitignore のカスタムメディアタイプ
gitignore テンプレートを取得するときに、このカスタムメディアタイプを使用できます。
application/vnd.github.raw
詳細については、「メディア タイプ」を参照してください。
Get all gitignore templates
Works with GitHub Apps
List all templates available to pass as an option when creating a repository.
HTTP response status codes
| Status code | Description |
|---|---|
200 | OK |
304 | Not modified |
Code samples
get/gitignore/templates
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://api.github.com/gitignore/templatesResponse
Status: 200[
"Actionscript",
"Android",
"AppceleratorTitanium",
"Autotools",
"Bancha",
"C",
"C++"
]Get a gitignore template
Works with GitHub Apps
The API also allows fetching the source of a single template. Use the raw media type to get the raw contents.
Parameters
| Headers |
|---|
| Name, Type, Description |
acceptstringSetting to |
| Path parameters |
| Name, Type, Description |
namestringRequired |
HTTP response status codes
| Status code | Description |
|---|---|
200 | OK |
304 | Not modified |
Code samples
get /gitignore /templates /{name}
curl \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <YOUR-TOKEN>" \
https://api.github.com/gitignore/templates/NAMEResponse
Status: 200{
"name": "C",
"source": "# Object files\n*.o\n\n# Libraries\n*.lib\n*.a\n\n# Shared objects (inc. Windows DLLs)\n*.dll\n*.so\n*.so.*\n*.dylib\n\n# Executables\n*.exe\n*.out\n*.app\n"
}