Git commit gets permission denied but works with --no-verify

Viewed 2107

When I run, git commit -m 'Test' am getting this message:

[INFO] Initializing environment for git@github.com:humitos/mirrors-autoflake.git.
An unexpected error has occurred: CalledProcessError: command: ('/usr/local/git/libexec/git-core/git', 'fetch', 'origin', '--tags')
return code: 128
expected return code: 0
stdout: (none)
stderr:
    git@github.com: Permission denied (publickey).
    fatal: Could not read from remote repository.

    Please make sure you have the correct access rights
    and the repository exists.

Check the log at /Users/amit/.cache/pre-commit/pre-commit.log

But if run, git commit -m 'Test' --no-verify, it works fine. Something is wrong with my pre commit hook, any ideas?

2 Answers

It appears your .pre-commit-config.yaml file references a git repository using an ssh url, but you don't have an ssh key for github configured

You can safely replace the reference to repo: git@github.com:humitos/mirrors-autoflake with repo: https://github.com/humitos/mirrors-autoflake (especially because this is a public repository)

I was able to fix it by remove below line from .gitconfig

[url "git@github.com:"]
        insteadOf = https://github.com/
Related