1

当我运行git commit -m 'Test'时,收到此消息:

[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

但如果运行,git commit -m 'Test' --no-verify它工作正常。我的预提交钩子有问题,有什么想法吗?

4

2 回答 2

1

您的文件似乎.pre-commit-config.yaml使用 ssh url 引用了 git 存储库,但您没有配置 github 的 ssh 密钥

您可以安全地替换对repo: git@github.com:humitos/mirrors-autoflakewith的引用repo: https://github.com/humitos/mirrors-autoflake(特别是因为这是一个公共存储库)

于 2020-08-20T03:27:00.837 回答
0

我可以通过从.gitconfig中删除以下行来修复它

[url "git@github.com:"]
        insteadOf = https://github.com/
于 2021-12-15T13:16:05.130 回答