简体   繁体   English

我如何允许自己从命令行推送到 github?

[英]How can I provide permission to myself to push to github from the command line?

I am trying for the first time to use git and GitHub to version control my project.我第一次尝试使用 git 和 GitHub 对我的项目进行版本控制。

Here is what i have done这是我所做的

  1. I added a new SSH Key to my machine using the docs " Generating a new SSH key and adding it to the ssh-agent "我使用文档“ 生成新的 SSH 密钥并将其添加到 ssh-agent ”向我的机器添加了一个新的 SSH 密钥
  2. I created a project on GitHub without readme.md file as recommended.我在 GitHub 上创建了一个项目,没有按照推荐的 readme.md 文件。
  3. 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但是, git push命令给我以下错误

remote: Permission to VENDORNAME/PROJECT-NAME.git denied to malhayek2014.远程:对 VENDORNAME/PROJECT-NAME.git 的许可被 malhayek2014 拒绝。 fatal: unable to access ' https://github.com/VENDORNAME/PROJECT-NAME.git/ ': The requested URL returned error: 403致命:无法访问“ https://github.com/VENDORNAME/PROJECT-NAME.git/ ”:请求的 URL 返回错误: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?如何与 Github 通信并向其推送代码?

When you want to use SSH for pushing and pulling you have to use the ssh URL (which looks like git@github.com:username/project.git ) and not the https URL. 当您想使用SSH进行推送和拉取时,必须使用ssh URL(看起来像git@github.com:username/project.git )而不是https URL。

In order to update an existing repository you can issue the following command: 为了更新现有存储库,您可以发出以下命令:

git remote set-url origin git@github.com:VENDOR-NAME/PROJECT-NAME.git

See https://help.github.com/articles/changing-a-remote-s-url/ 参见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. PS:您提供的错误消息表明您已使用https成功进行身份验证,但是,您没有强制推送到该存储库的权限-这与SSH问题无关。 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. 如果您是所有者之一,则需要将自己添加到团队中,或者要求所有者这样做-或将SSH密钥添加为部署密钥。

you can install github cli then everything will work你可以安装 github cli 然后一切都会工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM