jesseduffield / lazygit

simple terminal UI for git commands

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to ignore pre commit/push hooks for commit

KhizerRehan opened this issue · comments

The project i am working has some Husky hooks are installed like

  • pre-commit
  • pre-push

How i can commit without running such hooks on every commit.



Even after running an option does run pre-commit hooks defined in repo:


Your thoughts
What you have to say about the topic

Just to clarify, it happens even if you're running the mapping under w - commit changes without pre-commit hook?

Not OP, but I have probably the same setup.

  • Repo with git hooks set via husky
  • Run lazygit
  • Stage some changes
  • Press w and commit
  • Hooks still run (git commit is missing -n|--no-verify?)

This is what appears in the log(@)

  git commit -m "test"
Git output:
husky: Running pre-commit hook
[STARTED] Preparing lint-staged...
[SUCCESS] Preparing lint-staged...
[STARTED] Running tasks for staged files...


$ lazygit --version
commit=v0.34, build date=2022-04-27T13:28:28Z, build source=binaryRelease, version=0.34, os=linux, arch=amd64

Originally I had put the commit message in the log line git commit -m "test" as git commit -m "WIP". Sorry for the confusion.

@la-magra do you have a git.skipHookPrefix setup in your config.yml? Could you paste the entirety of your config, please?

Currently the pre-commit hook is skipped only if the commit message starts with git.skipHookPrefix, which is WIP by default. That clarifies why it didn't work for @KhizerRehan . Now that it's discovered why, we'll look into changing the logic that triggers skipping the pre-commit hook.

@mark2185 My config file in ~/.config/lazygit/config.yml is completely empty.

I did a quick test putting the default config into it:

$ lazygit -c > ~/.config/lazygit/config.yml

And now if I prefix my commits with "WIP" now the skipHooks command works as intended.
Edit: Disregard that, the skipHooks command always worked as intended (putting the WIP prefix in the commit skips the hooks), I didn't test this enough, sorry.

Replacing skipHookPrefix: WIP by skipHookPrefix: "" unfortunately does not allow the command to skip hooks since it displays the message You have not configured a commit message prefix for skipping hooks. Set "git.skipHookPrefix = 'WIP'" in your config.

Great! Now we know what's the cause and we can treat it!

In the meantime, please prefix your commit messages with WIP for when you want to skip the pre-commit hooks.

As a minor addendum until this issue is solved.

The following custom command does exactly what's required:

  - key: "W"
    command: git commit --no-verify
    context: "global"
    subprocess: true

lazygit is just that beautiful.

ezoic increase your site revenue