This post is mainly for Windows users who use
git in the command line to push their projects on Bitbucket. I recently encountered the following error while trying to push a project into a new repository:
Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists.
This error is caused because the URL you use to access your repository depends on the SSH protocol by default. The SSH authenticates you as a user and this error basically means the URL, for some reason, can’t be verified as authentic. One solution is to switch to the HTTPS URL format found here.
Did you follow the below steps in your Command Line after creating a new repository on Bitbucket?
$cd /path/to/my/repo $git remote add origin email@example.com:username/repositoryname.git $git push -u origin --all # pushes up the repo and its refs for the first time $git push -u origin --tags # pushes up any tags
Then do the following to switch to HTTPS authentication to fix the problem.
In your Terminal (Command Line), type the following:
$git rm remote origin #removes the SSH origin URL $git remote add origin https://firstname.lastname@example.org/accountname/reponame.git $git push -u origin --all
That should solve it!