github init错误

时间:2013-05-09 00:36:04

标签: ruby-on-rails git

我正在参加ruby.railstutorial.org课程(第3章),我需要创建一个新的github帐户。所以我开始正常。

$ git init
$ git commit -m "first commit"
$ git remote add origin git@github.com:<username>/sample_app.git
fatal: remote origin already exists. 

这很好,因为它只告诉我有一个github为此设置。这是真的,我可以在截图中看到。

enter image description here

github和我的教程的下一步是:

$ git push -u origin master
fatal: 'git@github.com<username>/sample_app.git' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.

可能导致这种情况的原因是什么?我没有被要求提供密码,我也觉得很奇怪。

2 个答案:

答案 0 :(得分:1)

由于您已经拥有一个具有该名称的github仓库,因此您只需克隆它而不是创建一个新仓库。在您的控制台中,尝试执行:

git clone git@github.com:XXXXXX/sample_app.git

然后继续添加你的第一个文件,提交它并推送它。

答案 1 :(得分:1)

你以某种方式得到了origin遥控器的无效网址;结肠丢失了。您可以像这样更新URL:

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

<username>是您的用户名。

或者,您可以手动编辑存储库配置文件.git/config并更改url部分下的[remote "origin"]值。

之后一切都应该正常。