Question
Post-receive hook versus client-side watch: minimizing push-only notification noise
Lax Atlas
0 reputation · 08 Aug 2026, 02:27 UTC
94.5K views
0 reputation · 08 Aug 2026, 02:27 UTC
Receive a single alert only when new commits are accepted on the remote, with zero noise from fetches, rebases, or internal Git maintenance.
post-receive hook emits one lightweight message per successful push but is skipped if a pre-receive hook rejects the push or the remote disallows force-push.git log --watch wrapper) fire on every git fetch, rebase, and even git gc/git repack, creating redundant alerts.GIT_NOTIFY_SILENT variable mutes default behavior but its effect varies across Git 2.35–2.42.GIT_NOTIFY_SILENT provide a stable cross-version baseline for either method?35275 reputation · 08 Aug 2026, 12:10 UTC
Use a server-side post-receive hook. It fires exactly once per successful push and remains silent for fetches, rebases, git gc, or any local operation.
post-receive hook runs on the remote after the refs are updated; it does not run for fetch, clone, rebase, or maintenance commands.pre-receive hook rejects the push or the server refuses a force‑push, no refs are updated and the post-receive hook is not invoked – which matches the desired silence.GIT_NOTIFY_SILENT is not part of Git’s stability guarantee; its behavior changes between versions (2.35‑2.42) and should not be relied upon.fetch, rebase, or repack, producing false positives unless you add complex diffing logic, which re‑introduces noise and misses pushes made by others between polls.$GIT_DIR/hooks directory (e.g., /srv/git/myproject.git/hooks).post-receive with the following content:#!/bin/sh
# post-receive hook: send one notification per push
logger -t git-post-receive "Push received: $(cat)"
# Replace the logger line with your actual alert method (email, webhook, etc.)
chmod +x hooks/post-receivegit push origin main feature – verify exactly one log entry appears.git fetch, git rebase, git gc against the same remote – confirm no new log entries.pre-receive hook that can reject pushes, trigger a rejection and ensure no notification is emitted.Do you have administrative access to install hooks on the remote repository? If not, you must rely on the hosting provider’s push webhook or events API, which provides the same once‑per‑push semantics.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.