【问题标题】:Git trying to push with MacOS username rather than config nameGit 尝试使用 MacOS 用户名而不是配置名称推送
【发布时间】:2018-08-26 00:29:29
【问题描述】:

我几天前成功推送到了一个仓库。我不确定发生了什么,但现在尝试推送正在抛出

SlyMachine:travel-site dev$ git push origin
dev@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.

我的 Mac 用户名是 dev,错误的第一行显示 dev@github.com,我认为它是从那里获取的。

我在 ~/.gitconfig 的全局配置只有我的姓名/电子邮件。

这是我在 .git/config 中的本地配置:

[core]
        repositoryformatversion = 0
        filemode = true
        bare = false
        logallrefupdates = true
        ignorecase = true
        precomposeunicode = true
[remote "origin"]
        url = ssh://github.com/danfoust/travel-site.git
        fetch = +refs/heads/*:refs/remotes/origin/*
[branch "master"]
        remote = origin
        merge = refs/heads/master

【问题讨论】:

    标签: git macos github terminal


    【解决方案1】:

    问题出在我的本地配置中。

    [remote "origin"]
            url = ssh://github.com/danfoust/travel-site.git
    

    我从某个地方获取了 url 语法,但它不正确或已过时。根据GitHub's Help page,我必须将远程用户设置为git

    git remote set-url origin git@github.com:danfoust/travel-site.git

    这解决了问题。

    【讨论】:

    • 你也可以拼写这个ssh://git@github.com/danfoust/travel-site.git。当然,这更长,但至少它以 URL“scheme”(whatever://)字符串开头... :-)
    猜你喜欢
    • 1970-01-01
    • 2021-01-16
    • 2019-08-08
    • 2019-09-04
    • 2020-09-28
    • 2013-10-21
    • 1970-01-01
    • 1970-01-01
    • 2021-01-12
    相关资源
    最近更新 更多