I use "git version 2.34.1" under "Ubuntu 22.04.5 LTS". I use always "git gui" command to do my work with git.
However it now comes up with a screen titled "prepare-commit-msg hook failed:"
with
"git: 'hook' is not a git command. See 'git --help'.
You must correct the above errors before committing.
I never used such hooks...
When I start "git gui" with --trace option I see:
/usr/lib/git-core/git --version
< git version 2.34.1
/usr/lib/git-core/git --exec-path
< /usr/lib/git-core
/usr/lib/git-core/git-rev-parse --git-dir
< .git
/usr/lib/git-core/git-rev-parse --show-prefix
<
/usr/lib/git-core/git-config --null --list
/usr/lib/git-core/git-rev-parse --show-toplevel
< /home/pberg/projects/kr2/hdllv-db
/usr/lib/git-core/git-rev-parse --is-bare-repository
< false
/usr/lib/git-core/git --html-path
< /usr/share/doc/git/html
/usr/lib/git-core/git-rev-parse --verify HEAD
< 12e35355e8fb0159fb9c4824f91ce9fa30b1de64
/usr/lib/git-core/git hook run --ignore-missing prepare-commit-msg -- .git/PREPARE_COMMIT_MSG 2>@1
/usr/lib/git-core/git-update-index -q --unmerged --ignore-missing --refresh
/usr/lib/git-core/git-diff-index --cached --ignore-submodules=dirty -z 12e35355e8fb0159fb9c4824f91ce9fa30b1de64
/usr/lib/git-core/git-diff-files -z
/usr/lib/git-core/git-ls-files --others -z --exclude-standard
MUST I define such a hook or what is to do?
Best regards Thomas
This error occurs because your version of git-gui
is trying to use the command git hook run
, which is not available in Git 2.34.1. The git hook
subcommand was introduced in Git 2.36.0.
How to fix:
sudo add-apt-repository ppa:git-core/ppa
sudo apt update
sudo apt install git
Then, verify the version with:
git --version
You do not need to define or configure any hooks. The error is caused by your git-gui
expecting a newer version of Git than what is installed.
Quick Answer:
Upgrade your Git installation to 2.36.0 or later to resolve this error with git gui
. No changes to hooks are needed.