Issue
I am trying for the first time to use git and GitHub to version control my project.
Here is what i have done
- I added a new SSH Key to my machine using the docs "href="https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/" rel="nofollow noreferrer">Generating a new SSH key and adding it to the ssh-agent"
- I created a project on GitHub without readme.md file as recommended.
- Using the command line, I changed directory to my project. Then, I executed the commands listed below
However, the git push
command is giving me the following error
remote: Permission to VENDORNAME/PROJECT-NAME.git denied to malhayek2014. fatal: unable to access 'https://github.com/VENDORNAME/PROJECT-NAME.git/': The requested URL returned error: 403
Here are the commands I ecexuted before running into the errors
echo "A message for the read me file" >> README.md
git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/VENDOR-NAME/PROJECT-NAME.git
git push -u origin master
How can I communicate with Github and push code to it?
Solution
When you want to use SSH for pushing and pulling you have to use the ssh URL (which looks like [email protected]:username/project.git
) and not the https URL.
In order to update an existing repository you can issue the following command:
git remote set-url origin [email protected]:VENDOR-NAME/PROJECT-NAME.git
See https://help.github.com/articles/changing-a-remote-s-url/
PS: The error message you provide indicates that you are successfully authenticated using https, however, you don't have persissions to push to that repository - that's independent to the SSH problem. You need to add yourself to the team if you are one of the owners or ask the owners to do so - or add your SSH key as a deployment key.
Answered By - MrTux Answer Checked By - Candace Johnson (WPSolving Volunteer)