Kallempudi Goutham
Kallempudi Goutham

Reputation: 33

pre-commit hook to read commit message

How to read commit message from git commit -m "message" using pre-commit hook. Or Is there any hook that reads commit message.

commit-msg hook can read the message but we need to provide a text file as input which I don't want.

Upvotes: 1

Views: 2478

Answers (2)

origin
origin

Reputation: 128

Once git commit -m "message" has been invoked, the message part gets stored in .git/COMMIT_EDITMSG file and commit-msg hook takes this as the input internally.

so you can use git commit -m "message" instead of git commit -F Filepath.

Upvotes: -1

Mureinik
Mureinik

Reputation: 311163

You can use the commit-msg hook. The $1 argument there contains the commit message, and if the check you need to perform fails, just return 1 to fail the commit.

Upvotes: 6

Related Questions