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

Running pre-commit hook

From
EAEd Avis <eda@waniasset.com>
Date
Jul 31, 2015, 14:57 UTC
Message-ID
<loom.20150731T164948-964@post.gmane.org>
Currently, git commit --dry-run does not run any hooks, not even pre-commit:

% mkdir test % cd test % git init Initialized empty Git repository in /home/eda/test/.git/ % ln -s /bin/false .git/hooks/pre-commit % touch a % git add a % git commit --dry-run -m. a >/dev/null && echo yes yes % git commit -m. a && echo yes (fails)

It would sometimes be useful to run the pre-commit hook without committing, for example to get some initial checks done before prompting the user to enter a log message. (git commit itself works this way, of course, but I am thinking of development environments and editors that interface to git.)

Is there a way to do a dry run commit that also runs some of the hooks?
-- 
Ed Avis <eda@waniasset.com>
Message 1 of 1 in “Running pre-commit hook”
  1. Ed AvisJul 31, 2015

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.