2

I'm just trying to push my local master to the remote repository on github, but this is not possible. I have already made a repository in my github directory - on the website, and the app that I'm working on is simple in that I've only been working on the local master - no branches or anything.

When I try 'git push -u origin master' in the terminal, the reply is:

permission denied (publickey)
fatal: could not read from remote repository

When I try 'git push', the response is:

fatal: the current branch master has no upstream branch. To push the 
current branch and set the remote as upstream, use 'git push --set-
upstream origin master'

But when I try 'git push --set-upstream origin master' I get:

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

Please make sure you have the correct access rights
and the repository exists.

I've been reading as much as I can online on this, but I can't get anywhere, so some advice would be much appreciated, thanks :-)

Roman Kiselenko
  • 43,210
  • 9
  • 91
  • 103
Robert
  • 109
  • 3
  • 13
  • 2
    Please check with your remote by using following command `git remote -v`. It will show you some urls like this : origin your_url (fetch) origin your_url (push) – Akshay Borade Oct 03 '17 at 12:59
  • Have you setup your ssh correctly? Or have setup shh at all? Atlassian has a excellent guide https://confluence.atlassian.com/bitbucket/set-up-an-ssh-key-728138079.html. – nishon.tan Oct 03 '17 at 13:03
  • After this you need to setup your ssh. If you clone your repository with ssh url and If you clone your repository with https url you need to enter your password on each actions (pull. push and fetch). – Akshay Borade Oct 03 '17 at 13:05
  • Thank you both :-) – Robert Oct 03 '17 at 13:11
  • Possible duplicate of [Git - Permission denied (publickey)](https://stackoverflow.com/questions/2643502/git-permission-denied-publickey) – phd Oct 03 '17 at 13:16

3 Answers3

0

You probably do not have permission to read or write from your created repository. You will need to generate a new SSH key and add the public key to your Github account. If you do not know how to do that it is described in detail on https://help.github.com/articles/connecting-to-github-with-ssh/.

0

A bit late, but for any one else stumbling upon this, this worked for me.

  1. Open Powershell
  2. Type in "ssh-keygen" (generates your ssh key)
  3. Type in "cat ~/.ssh/id_rsa.pub" (gets your key)
  4. Should look something like this - "ssh-rsa WHOOOOOOLEBUNCHOFTEXT"
  5. Copy it and go to your repo SSH Keys settings (should be in the settings section somewhere. - Gitlab's settings is here https://gitlab.com/-/profile/keys)
  6. Create a new key and paste your ssh key in there.
  7. Ka-bAM - Should be able to push now
Ruan
  • 3,969
  • 10
  • 60
  • 87
-1

-- If you want to update branch ---

git checkout master

git pull origin master

git checkout YOUR-BRANCH

git rebase master

-- if you want to commit your code ---

git add -A

git commit -m "any comment"

git push origin YOUR-BRANCH

git checkout master

git pull origin master

git checkout YOUR-BRANCH

git rebase master

and finally

git push origin YOUR BRANCH

and after you will submit merge request

Ravi Chauhan
  • 1,409
  • 13
  • 26