I have github configured for push on macOS. But I need to push to bitbucket I created a remote repository there, cloned it into my project

remote add origin git@bitbucket.org:xxx 

fatal: remote origin already exists.

 git push origin master 

Permission denied (publickey). fatal: Could not read from remote repository.

Please make sure you have the repository exists.

How to set it up correctly? C github everything works for me.

  • use another name for bitbcuket once the origin taken from you for github. For example, remote add bitbucket git@bitbucket.org:xxx . - 4per
  • And then git push bitbucket master . Well, with the rights you also have a problem, as they wrote in the answer .. - 4per
  • In general, you have a problem with ssh keys .. - 4per

1 answer 1

I am sure that the problem is that you have specified a login and password in the Git configuration from github , but you need a bitbucket . Therefore, he gives you Permission denied

You can change it like this:

git config --global user.name "myusername"

In any case, the problem is precisely this.

  • So then I’ll have a problem with github if I change git --global, or not? - mtb
  • identical login and password for both repositories can be? - pavlofff
  • No, there will not be, I have two projects, one for git, another for butbucket, I just change users and everything is okay. - Zicrael
  • pavlofff everything can be, I described the situation in which I received the same error, and how I solved it. So maybe it will be useful to the author. - Zicrael
  • And somehow you can locally configure for the project so as not to change the user every time? - mtb 1:59