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 →
- Use push rulesets (available for repositories in organisations on paid plans) to restrict file extensions, file paths and maximum file size.
- Apply them org-wide so new repos inherit the policy.
- Pair with secret scanning push protection for credentials inside files.
- Self-hosted alternative: a
pre-receivehook that inspectsgit rev-listof 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.
More on Protection, Hooks and Policy
You are asked to protect `main`. Which rules do you turn on?BeginnerClassic branch protection or repository rulesets: which do you use?IntermediateA required status check never reports and the PR is stuck as "Expected — Waiting for status".IntermediateProduction is down and the fix needs to merge now, but approvals are required.IntermediateYou want to stop developers from committing obvious mistakes like debug prints, trailing whitespace or secrets.BeginnerHooks in `.git/hooks` are not shared with the team. How do you distribute them?Intermediate