Skip to main content

此版本的 GitHub Enterprise Server 已于以下日期停止服务 2026-06-02. 即使针对重大安全问题,也不会发布补丁。 为了获得更好的性能、更高的安全性和新功能,请升级到最新版本的 GitHub Enterprise。 如需升级帮助,请联系 GitHub Enterprise 支持

Working with push protection from the REST API

Learn your options for unblocking your push to GitHub using the REST API if secret scanning detects a secret in the content of your API request.

谁可以使用此功能?

具有写入访问权限的用户

在本文中

About push protection from the REST API

Push protection prevents you from accidentally committing secrets to a repository by blocking pushes containing supported secrets.

The "Create a blob" and "Create or update file contents" endpoints in the REST API include push protection. See Git Blob 的 REST API 端点 and 存储库内容的 REST API 终结点.

If you make a request with these endpoints whose content includes a supported secret, the REST API will return a 409 error, indicating that a secret has been detected.

To resolve the error, you can either:

  • Remove the secret from the content of your API request before trying again.
  • Create a push protection bypass: You can bypass push protection using the "Create a push protection bypass" endpoint. For more information, see 适用于机密扫描的 REST API 终结点.

Further reading