Interview Prep/Git & GitHub/Protection, Hooks and Policy

Security wants to stop anyone pushing `.pem`, `.exe` or files over 50 MB, with no client trust.

AdvancedScenarioProtection, Hooks and Policy
Answer

Situation read → The restriction must be applied at push time, server-side.

What I'd do →

  1. Use push rulesets (available for repositories in organisations on paid plans) to restrict file extensions, file paths and maximum file size.
  2. Apply them org-wide so new repos inherit the policy.
  3. Pair with secret scanning push protection for credentials inside files.
  4. Self-hosted alternative: a pre-receive hook that inspects git rev-list of new objects.

Why → GitHub rejects the push before the objects land, so nothing sensitive reaches the remote.

Interview tip → Know that GitHub's hard limits are 100 MB per file and a warning at 50 MB.

All Git & GitHub questions Roadmap: Git & GitHub

More on Protection, Hooks and Policy