简体   繁体   English

无法推送到我的git存储库

[英]Can't push to my git repository

I'm a n00b and i'm learning rails. 我是n00b,正在学习rails。 I'm having problems pushing my local repository to my github. 我在将本地存储库推送到github时遇到问题。 I'm doing the ruby on rails tutorial and i've got my github account set up. 我正在做Rails上的ruby教程,并且已经设置了github帐户。 i'm on step 1.3.4 and typing: 我在步骤1.3.4并输入:

C:\Sites\rails_projects\first_app> git remote add origin https://github.com/<username>/first_app.git

returns 回报

fatal: remote origin already exitst

i figured this is a good thing because it can see the repo. 我认为这是一件好事,因为它可以看到回购。 but when i push i get: 但是当我推动我得到:

C:\Sites\rails_projects\first_app> git push -u origin master
Permission denied (publickey)
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists.

I know the repository exists because it in my git account but when i use github for windows i get an error also. 我知道存储库的存在是因为它在我的git帐户中,但是当我将github用于Windows时,我也会收到一个错误。 i think it may be a problem with my ssh keys. 我认为这可能与我的ssh密钥有关。 i'm trying to learn rails and any help would be greatly appreciated. 我正在尝试学习Rails,任何帮助将不胜感激。

You can choose between 2 protocols when connecting to GitHub: SSH or HTTPS . 连接到GitHub时,您可以选择以下两种协议: SSHHTTPS It's hard to say which one is better (it is a separate question), but HTTPS is a little bit easier to setup because you don't need to bother with SSH -keys. 很难说哪个更好(这是一个单独的问题),但是HTTPS的设置稍微容易一些,因为您无需费心SSH -keys。

Currently, according to the error, you have configured SSH protocol, but if you don't want to generate keys, you can easily change it to HTTPS . 当前,根据错误,您已经配置了SSH协议,但是如果您不想生成密钥,则可以轻松地将其更改为HTTPS In order to do this run: 为了执行此操作:

git remote set-url origin https://<username>@github.com/<username>/first_app.git

Pay attention that I added <username>@ in the beginning. 请注意,我在开始时添加了<username>@ This means that you wouldn't need to enter your username each time you push. 这意味着您无需在每次按下时都输入用户名。 You can also configure git to remember your password for certain period of time. 您还可以配置git在特定时间段内记住您的密码。 Look at GitHub docs how to do this: https://help.github.com/articles/set-up-git#password-caching 查看GitHub文档如何执行此操作: https : //help.github.com/articles/set-up-git#password-caching

You probably didn't add your public key to Github. 您可能没有将公共密钥添加到Github。 Follow this guide to do it: https://help.github.com/articles/generating-ssh-keys 按照此指南进行操作: https : //help.github.com/articles/generating-ssh-keys

Another advise: 另一个建议:

Don't try to develop Rails applications with Windows! 不要尝试使用Windows开发Rails应用程序! You better use Virtual Image, for example: VirtualBox image 最好使用虚拟映像,例如: VirtualBox映像

Or use Cloud Development Environment like: Nitrous.io 或使用以下云开发环境: Nitrous.io

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

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