-1

I have have been using my personal git and github accounts on my work computer Windows10 but would like to start using work accounts instead.

I have created a new work account and repository on github. After cloning the repository to my local machine, making a commit and then trying to push I get the following error.

git push
To https://github.com/workuser/workrepo.git
 ! [remote rejected] release -> release (permission denied)
error: failed to push some refs to 
'https://github.com/workuser/workrepo.git'

I am using VS Code

If I run

git config --get user.email

I get my work email

Within the terminal in VS Code

git remote -v
origin  https://github.com/workuser/workrepo.git (fetch)
origin  https://github.com/workuser/workrepo.git (push)

What do I need to do so I can push to my work repo on github

Thanks

2 Answers2

0

You tried to push to the https link of your repo and that won't work (without manually typing your username and password). You have to use the ssh version of the link!

To change the link for the remote origin open a console in the directory of your repo and type:

git remote set-url origin git@github.com:workuser/workrepo.git

Now you should be able to push to github.

Sebastian Stigler
  • 6,819
  • 2
  • 29
  • 31
  • After doing that I get: git push Permission denied (publickey). fatal: Could not read from remote repository. Please make sure you have the correct access rights and the repository exists. – Graeme Benzie Sep 22 '17 at 08:46
  • It never asks for my username and password – Graeme Benzie Sep 22 '17 at 08:48
  • It will ask for the username and password if you do a `git push origin master` from the console. I just tried it myself. – Sebastian Stigler Sep 22 '17 at 08:52
  • Your errormessage could be because of a typo in the ssh link. Just go to your repo on github, click the 'clone or download' button. On the popup click 'use ssh' and copy the displayed link. If it still not work, check if you added your ssh key to your accout. – Sebastian Stigler Sep 22 '17 at 08:56
0

I did as Sebastian suggested ( thank you ) and run the command

git remote set-url origin git@github.com:workuser/workrepo.git

I copied my SSH key locally from the file C:\Users\graeme.ssh\id_rsa.pub

and went to https://github.com/settings/keys and added it there