{"meta":{"title":"命令行中的推送保护","intro":"了解 GitHub 如何使用推送保护来防止通过命令行泄露机密信息。","product":"安全性和代码质量","breadcrumbs":[{"href":"/zh/enterprise-server@3.22/code-security","title":"安全性和代码质量"},{"href":"/zh/enterprise-server@3.22/code-security/concepts","title":"Concepts"},{"href":"/zh/enterprise-server@3.22/code-security/concepts/secret-security","title":"机密安全性"},{"href":"/zh/enterprise-server@3.22/code-security/concepts/secret-security/command-line-push-protection","title":"命令行推送保护"}],"documentType":"article"},"body":"# 命令行中的推送保护\n\n了解 GitHub 如何使用推送保护来防止通过命令行泄露机密信息。\n\n推送保护通过阻止包含支持的机密的推送，防止你无意将机密提交到存储库。\n\n尝试将受支持的机密从命令行推送到受推送保护保护的存储库时， GitHub 将阻止推送。\n\n你可以选择做其中之一：\n\n* ```\n            从你的分支中**删除**机密。 有关详细信息，请参阅[解决被阻止的推送](/code-security/how-tos/secure-your-secrets/work-with-leak-prevention/push-protection-on-the-command-line#resolving-a-blocked-push)。\n  ```\n* **按照提供的 URL** 查看你可使用的允许推送的选项。 有关详细信息，请参阅[绕过推送保护](/zh/enterprise-server@3.22/code-security/how-tos/secure-your-secrets/work-with-leak-prevention/push-protection-on-the-command-line#bypassing-push-protection)和[请求绕过权限](/zh/enterprise-server@3.22/code-security/how-tos/secure-your-secrets/work-with-leak-prevention/push-protection-on-the-command-line#requesting-bypass-privileges)。\n\n在命令行上，每次最多显示 5 个检测到的机密。 如果存储库中检测到特定机密且警报已存在， GitHub 则不会阻止该机密。\n\n如果确认机密是真实的，并且你打算稍后修补它，你应该致力于尽快修补机密。 例如，你可以撤销该机密，并从存储库的提交历史记录中删除机密。 必须撤销已公开的真实机密，以避免未经授权的访问。 在撤销机密之前，可以考虑先轮换机密。 有关详细信息，请参阅“[从存储库中删除敏感数据](/zh/enterprise-server@3.22/authentication/keeping-your-account-and-data-secure/removing-sensitive-data-from-a-repository)”。\n\n> \\[!NOTE]\n>\n> * 如果 Git 配置支持推送到多个分支，而不仅仅是推送到当前分支，则由于附加和意外的引用被推送，你的推送可能被阻止。 有关详细信息，请参阅 Git 文档中的 [`push.default` 选项](https://git-scm.com/docs/git-config#Documentation/git-config.txt-pushdefault)。\n> * 如果在推送超时后进行 secret scanning，GitHub 仍将在推送后扫描你的提交有无机密。"}