Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails github初始化错误_Ruby On Rails_Git - Fatal编程技术网

Ruby on rails github初始化错误

Ruby on rails github初始化错误,ruby-on-rails,git,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. $git init $git commit-m“首次提交” $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. 
$git init
$git commit-m“首次提交”
$git远程添加源git@github.com:/sample\u app.git
致命:远程源已存在。
这很好,因为它只是告诉我,有一个github为此而设置。这是真的,我可以在截图中看到

根据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.
$git push-u原始主机
致命的:'git@github.com/示例_app.git'似乎不是git存储库
致命:无法从远程存储库读取。
请确保您拥有正确的访问权限
并且存储库存在。

这可能是什么原因造成的?我还没有被要求输入一个我也觉得奇怪的密码

既然您已经有了一个同名的github repo,您只需克隆它,而不是创建一个新的。在控制台中,尝试执行以下操作:

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

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

不知何故,您的
源文件
远程文件的URL无效;结肠不见了。您可以按如下方式更新URL:

git remote set-url origin git@github.com:<username>/sample_app.git
git远程设置url源git@github.com:/sample\u app.git
其中
是您的用户名

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


然后一切都会好起来。

'git@github.com/示例\u app.git'
文字错误?如果你替换了你的实际用户名,看起来你忘记了冒号。你能显示
git remote-v
的输出吗?当你去添加源代码时,似乎有一个东西已经被称为源代码了。如果你能回答@pktangyue的问题,那将非常有帮助。或者,您可以将其添加为名为
github
的远程设备,然后执行
git push-u github master
@Cairnarvon我最初也这么认为,但冒号是用原始命令编写的。@pktangyue@sigmavirus24<代码>git remote-v
显示herokugit@heroku.com:.git(fetch)
herokugit@heroku.com:.git(推送)
origingit@github.com/示例\u app.git(提取)
来源git@github.com/示例_app.git(推送)
同样,github.com后面似乎没有冒号,但我在命令中放了“:”。不幸的是,这不起作用<代码>$git克隆git@github.com:/sample\u app.git显示以下输出
致命:目标路径“sample\u app”已存在且不是空目录。
您的问题是否已解决?看起来已经有一个名为“sample\u app”的目录,您正试图在其中运行
git clone…
命令。再次尝试运行git clone…之前,请尝试删除“sample\u app”目录或转到其他目录。