I created a new repository and I\'m running into a strange error. I\'ve used Git before on Bitbucket but I just reformatted and now I can\'t seem to get Git to work. After
I had this issue and I thought I was crazy. I have been using SSH for 20 years. and git over SSH since 2012... but why couldn't I fetch my bitbucket repository on my home computer?
well, I have two bitbucket accounts and had 4 SSH keys loaded inside my agent. even if my .ssh/config was configured to use the right key. when ssh was initializing the connection, it was using them in order loaded into the agent. so I was getting logged into my personal bitbucket account.
then getting a Forbidden error trying to fetch the repo. makes sense.
I unloaded the key from the agent
ssh-add -d ~/.ssh/personal_rsa
then I could fetch the repos.
... Later I found out I can force it to use the specified identity only
Host bitbucket.org-user2
HostName bitbucket.org
User git
IdentityFile ~/.ssh/user2
IdentitiesOnly yes
I didn't know about that last option IdentitiesOnly
from the bitbucket documentation itself
https://blog.developer.atlassian.com/different-ssh-keys-multiple-bitbucket-accounts/
Just try
git remote add origin <HTTP URL>
Reformatted means you probably deleted your public and private ssh keys (in ~/.ssh).
You need to regenerate them and publish your public ssh key on your BitBucket profile, as documented in "Use the SSH protocol with Bitbucket", following "Set up SSH for Git with GitBash".
Accounts->Manage Accounts->SSH Keys:
Then:
Images from "Integrating Mercurial/BitBucket with JetBrains software"
Get the ssh done as in the Atlassian tutorial and make sure the private key is being pasted in the profile, not in the repository :)
I solved this by removing the remote using command:
git remote remove origin
and then tried to add remote using https url instead of ssh
git remote add origin httpsUrl
It asks for github credentials. Enter credentials and then try pushing to git using:
git push origin master
Just need config file under ~/.ssh directory
ref : https://confluence.atlassian.com/bitbucket/set-up-ssh-for-git-728138079.html
add bellow configuration in config file
Host bitbucket.org
IdentityFile ~/.ssh/<privatekeyfile>