git 推送显示错误的用户名

git push shows wrong username

我查了很多关于这个的帖子,但没有任何帮助。

有一个类似这样的远程仓库:https://github.com/cakes/blue.git

全局gitconfig是:

$ cat ~/.gitconfig
[user]
        name = blake.shaw
[http]
        sslCaInfo = C:/bin/certificate.crt

这需要证书,因此将其作为 http.sslCaInfo 并且证书也已添加到 git bin 文件夹中。

克隆后,远程源 url 被设置为:git@github.com:cakes/blue.git

id_rsa 和 id_rsa.pub 也被创建。 id_rsa.pub 已添加到 git 集线器(远程)中的 ssh 密钥。

当我尝试执行 git push origin master 时,它抛出错误:

ERROR: Permission to cakes/blue.git denied to blake-shaw
fatal: Could not read from remote repository.

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

有两个问题:

  1. url 中的用户名显示 blake-shaw 而不是 blake.shaw。如何重置?

  2. 尝试使用 url 作为:https://github.com/cakes/blue.git 并使用源代码树,尝试推送但随后抛出以下错误:

    remote: Permission to cakes/blue.git denied to blake.shaw.
    fatal: unable to access 'https://github.com/cakes/blue.git/': The requested URL returned error: 403
    
  1. 除了生成的 id_rsa 和 id_rsa.pub 之外,~/.ssh 目录中是否还有其他文件?

  2. 克隆的远程仓库应该以SSL模式复制才能正常工作(不必每次都输入用户名和密码)。使用 SSL 地址再次尝试克隆 - git clone git@github.com:cakes/blue.git

The username in the url says blake-shaw instead of blake.shaw. How to reset it?

检查您的 ~/.ssh/id_rsa 是否已注册到 github.com/blake.shaw 帐户。

Tried using the url as : https://github.com/cakes/blue.git

检查使用 SourceTree 推送时使用的用户帐户。

但更一般地说,确保回购 blue.gitgithub.com/blake.shaw 用户帐户下,否则它不会工作(因为 blake.shaw 不是回购的所有者)