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
This error also shows up when the repository does not exist. I tried all the answers until I saw the repo name was missing a dash
I got this error
Connection to bitbucket.org closed by remote host. fatal: Could not read from remote repository. Please make sure you have the correct access rights.
Then i tried
git config --global user.email "you@example.com"
worked without quotes.
Git has changed some of its repo instructions - check that you have connected your local repo to the Git cloud - check each of these steps to see if you have missed any.
Git documentation[https://docs.github.com/en/free-pro-team@latest/github/authenticating-to-github/connecting-to-github-with-ssh] if you prefer following documentation - it is far more detailed and worth reading to understand why the steps below have been summarised.
My Git Checklist:-
$rm -rf .git
which recursively removes gitwhich git
it should say /usr/local/bin/git
- if you are install git with Homebrew $brew install git
$git config --global user.name "Your Name"
$git config --global user.email "you@example.com"
$git config --global core.ignorecase false
If you have made a mistake you can update the file $ls -a
to locate file then $open .gitignore
and edit it, save and close.
ssh-keygen -t rsa -C "your_email@example.com"
SAVE THE KEYssh-add ~/.ssh/id_rsa
You can also find it by clicking your profile image and the edit key under it in the left nav.
Copy your key to the clipboard with the terminal command:
pbcopy < ~/.ssh/id_rsa.pub
In the Title field put something that identifies your machine, like YOUR_NAME's MacBook Air
In the Key field just hit cmd + V to paste the key that you created earlier - do not add or remove and characters or whitespace to the key
Click Add key and check everything works in the terminal by typing:
ssh -T git@github.com
You should see the following message:
Hi YOUR_NAME! You've successfully authenticated, but GitHub does not provide shell access.
Now that your local machine is connected to the cloud you can create a repo online or on your local machine. Git has changed the name master for a branch main. When linking repos it is easier to use the HTTPS key rather than the SSH key. While you need the SSH to link the repos initially to avoid the error in the question.
Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
Follow the steps you now get on your repo - GitHub has added an additional step to create a branch (time of writing Oct 2020).
to create a new repository on the command line echo "# testing-with-jest" >> README.md git init git add README.md git commit -m "first commit" git branch -M main git remote add origin — (use HTTPS url not SSH) git push -u origin main
to push an existing repository from the command line git remote add origin (use HTTPS url not SSH) git branch -M main git push -u origin main
If you get it wrong you can always start all over by removing the initialisation from the git folder in your local machine $rm -rf .git
and start afresh - but it is useful to check first that none of the steps above are missed and always the best source of truth is the documentation - even if it takes longer to read and understand!
If you are using SourceTree (I'm using 2.4.1), I found a simpler way to generate an SSH key and add it to my Bitbucket settings. This solved the problem for me.
I received a confirmation email from Bitbucket that an SSH key had been added to my account.
For reference, on macOS, using Terminal, you can use the following command to see the keys generated for your device. This is where the key you generated is stored.
ls -la ~/.ssh
As others have stated, this documentation helped me: Use the SSH protocol with Bitbucket Cloud
This is probably caused by having multiple SSH keys in SSH agent (and/or BitBucket). Check Atlassian documentation for the workaround for this
I had the same problem. My SSH keys were set correctly. I fixed this problem like this.
After creating new project in Bitbucket, use clone. Enter cloning command in terminal and it should clone empty project to your computer. After that you can copy your files to this directory and start committing and pushing to bitbucket.