git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Detecting source of a push in a pre-receive hook

From
Chris Packham <judge.packham@gmail.com>
Date
Jan 20, 2026, 20:45 UTC
Message-ID
<CAFOYHZDcFJBiZwmposZVGmymmRz1XOaXP8iCRgTDVcsWPTH=6g@mail.gmail.com>
In-Reply-To
<CAFOYHZDnXQOcDmzwf1WRpZpNRAs-R2YOBh3ru0mr0ffrMLB=9Q@mail.gmail.com>
Hi Git,

At $dayjob we're moving from a mix of plain git repositories on a server accessed via ssh with a secondary Gerrit server tacked on the side for code review to using the Gerrit server as the primary source of truth.

So that people don't have to update origin.url for all their local repositories, we're using the Gerrit replication plugin to keep the old server in sync (and will likely do so for the foreseeable future). We have installed a pre-receive hook for the migrated repositories on the old server that rejects pushes from anyone except the user that the replication runs as.

For various reasons we also have a CI system that pushes some things (mostly tags but some automated merge commits as well) that runs as the same user. We'd really like to be able to have the pre-receive hook reject pushes from the CI system but allow them from the Gerrit server. Does the pre-receive hook have any way of knowing the source of a push operation?

Thanks, Chris

Next: rsbecker@nexbridge.com
Message 1 of 4 in “Detecting source of a push in a pre-receive hook”
  1. Chris PackhamJan 20, 2026
  2. rsbecker@nexbridge.comJan 20, 2026
  3. Jeff KingJan 21, 2026
  4. Jeff KingJan 21, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.