gitignore 用 REST API エンドポイント
REST API を使用して、ファイルとディレクトリを無視するために使用できる .gitignore テンプレートを取得します。
gitignore について
API を介して GitHub で新しいリポジトリを作成するとき、.gitignore テンプレートを指定して作成時にリポジトリに適用できます。 REST API を使って、GitHub .gitignore リポジトリから .gitignore テンプレートを取得できます。
Get all gitignore templates
List all templates available to pass as an option when creating a repository.
"Get all gitignore templates" のきめ細かいアクセス トークン
このエンドポイントは、次の粒度の細かいトークンの種類で動作します:
粒度の細かいトークンにはアクセス許可が必要ありません。
パブリック リソースのみが要求された場合、このエンドポイントは認証なしで使用できます。
"Get all gitignore templates" の HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
200 | OK |
304 | Not modified |
"Get all gitignore templates" のコード サンプル
GHE.com で GitHub にアクセスする場合は、api.github.com を api.SUBDOMAIN.ghe.com にあるエンタープライズの専用サブドメインに置き換えます。
要求の例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/gitignore/templatesResponse
Status: 200[
"Actionscript",
"Android",
"AppceleratorTitanium",
"Autotools",
"Bancha",
"C",
"C++"
]Get a gitignore template
Get the content of a gitignore template.
This endpoint supports the following custom media types. For more information, see "Media types."
application/vnd.github.raw+json: Returns the raw .gitignore contents.
"Get a gitignore template" のきめ細かいアクセス トークン
このエンドポイントは、次の粒度の細かいトークンの種類で動作します:
粒度の細かいトークンにはアクセス許可が必要ありません。
パブリック リソースのみが要求された場合、このエンドポイントは認証なしで使用できます。
"Get a gitignore template" のパラメーター
| 名前, Type, 説明 |
|---|
accept string Setting to |
| 名前, Type, 説明 |
|---|
name string 必須 |
"Get a gitignore template" の HTTP 応答状態コード
| 状態コード | 説明 |
|---|---|
200 | OK |
304 | Not modified |
"Get a gitignore template" のコード サンプル
GHE.com で GitHub にアクセスする場合は、api.github.com を api.SUBDOMAIN.ghe.com にあるエンタープライズの専用サブドメインに置き換えます。
要求の例
curl -L \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
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"
}