cstack
cstack

Reputation: 2232

`git push heroku master` fails because it is using the wrong email address

I created a rails app with

$ rails new appname
$ cd appname

I initialized it as a git repo

$ git init
$ git add .
$ git commit -m 'init'

I logged into heroku

$ heroku login
Email: [email protected]
Password (typing will be hidden):

I created the heroku app

$ heroku create
Creating radiant-bayou-6540... done, stack is cedar
http://radiant-bayou-6540.herokuapp.com/ | [email protected]:radiant-bayou-6540.git
Git remote heroku added

I tried to push to heroku

$ git push heroku master
!  Your account [email protected] does not have access to radiant-bayou-6540.

Wait what? I didn't log in with [email protected], I logged in with [email protected]. Let's look at git

$ git config user.email
[email protected]

What?! Why does heroku think I'm logging in with [email protected]

Upvotes: 2

Views: 772

Answers (3)

Harikrishna R
Harikrishna R

Reputation: 119

In my case, I simply had to switch to using ssh.

git config --global url.ssh://[email protected]/.insteadOf https://git.heroku.com/

If the heroku remote uses https, git seems to pull the credentials from elsewhere.

Upvotes: 0

Tonmoy
Tonmoy

Reputation: 174

Removing known_hosts entry for ssh should help. For linux and mac it is in the $HOME/.ssh directory

Upvotes: 0

JTG
JTG

Reputation: 8826

Source

Your account SSH keys is tied to your old email. You are going to have to transfer it over to your new account

$ heroku login
Enter your Heroku credentials.
Email: [email protected]
Password: 

$ heroku keys:remove [email protected]

and add it to your new account

$ heroku login
Enter your Heroku credentials.
Email: [email protected]
Password: 

$ heroku keys:add

Failing that, try recreating and add a new ssh key

Upvotes: 3

Related Questions