尝试找到所有有用的答案here https://stackoverflow.com/questions/20586992/your-account-someoneelsegmail-com-does-not-have-access-to-app-name.
对我来说,我有两个不同的 heroku 帐户,每个帐户都与不同的 git 存储库关联。所以我必须告诉heroku为每个密钥使用特定的SSH密钥(显然,不仅仅是第一个可用的密钥,这似乎是默认行为)。对我有用的确切方法是按照以下步骤操作here https://stackoverflow.com/a/9149518/4294745进而here https://stackoverflow.com/a/13518981/4294745.
细节:
创建一个新的 rsa 密钥:指定您想要的任何电子邮件,并选择一个易于您记住并与特定 heroku 应用程序关联的名称。或者您可以将其命名为 /id_rsa_herokualt。
$ ssh-keygen -t rsa -C "youremail[at]domain.com" -f ~/.ssh/id_rsa_myherokuapp
添加到您的机器:确保输入的文件名与您在上一步中指定的文件名完全相同。
$ ssh-add ~/.ssh/id_rsa_myherokuapp
添加到 Heroku:这假设您已经使用登录到herokuheroku login
.
$ heroku keys:add ~/.ssh/id_rsa_myherokuapp.pub
将 heroku.com 的备用主机添加到 ~/.ssh/config 中。通过转到 Finder 并按 command + shift + g 并输入 ~/.ssh/ 找到此文件。在文本编辑器中打开配置文件,添加以下文本,然后保存:
Host heroku-alt
HostName heroku.com
IdentityFile ~/.ssh/id_rsa_myherokuapp
更新项目中的 .git/config 以使用主机别名。通过转到 Finder 并按 command + shift + g 并输入 ~/path/to/your/repository/.git 找到此文件。在文本编辑器中打开配置文件,添加以下文本,然后保存:
[remote "heroku"]
url = git@heroku-alt:myherokuapp.git
fetch = +refs/heads/*:refs/remotes/heroku/*
解释:通过在特定项目的 .git/config 文件远程中选择 heroku 和 heroku-alt,您可以管理哪些项目使用哪些凭证。