Reputation: 2610
Problem
I am getting the below error while pushing or pulling data from bitbucket.
git fetch --all
Fetching origin
Forbidden
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
I have the same ssh keys on my ~/.ssh/project_ssh_key
on bitbucket & my mac.
What I have tried to fix it
I tried to create a new ssh file and use the same using the below command.
eval "$(ssh-agent -s)"
ssh-add -K ~/.ssh/my_project_new_private_key
I have added the newly created key in bitbucket in ** Personal Settings --> ssh keys ** and pasted the public key but no luck.
I also tried ssh -T git@bitbucket
& got the output as
logged in as chakreshwar
You can use git or hg to connect to Bitbucket. Shell access is disabled
Earlier everything was working with the old key before I did the below
1. I realized that my RoR application is not using **.ruby-version** & **.ruby-gemset**
2. I created a new gemset & use that gemset.
3. Move all the references from default to newly created gemset.
4. Bundle install and rails s to make sure everything works.
5. Delete all the old git branches from local which are no longer in use.
Upvotes: 3
Views: 2168
Reputation: 1329092
Check first if you have a ~/.ssh/config
file.
Because if ssh -T git@bitbucket
works, that means you have a Host bitbucket
entry which references the right private key.
But in that case, git remote -v must reflects an SSH URL actually using that Host entry:
bitbucket:<me>/<myrepo>
(assuming your config file also have a User git
line)
Not bitbucket.org
, but bitbucket
.
So:
cd /apth/to/local/repo
git remote set-url origin bitbucket:<me>/<myrepo>
Upvotes: 3