我在 Michael Hartl 的 Ruby on Rails 教程的第 2 章中,我在命令行中输入了以下内容:
$ git init
$ git add .
$ git commit -m "Initial commit"
$ git remote add github https://github.com/themaktravels/demo_app.git
fatal: remote github already exists.
$ git push -u github master
Username:
Password:
To https://github.com/themaktravels/first_app.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/themaktravels/first_app.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes (e.g. 'git pull') before pushing again. See the
'Note about fast-forwards' section of 'git push --help' for details.
我看到在指出 Github 存在之前我遇到了一个致命错误,但我认为这没关系,因为我之前在不同的存储库中提交了 Git。我注意到,当我 时$ git push -u Github master
,结果是 git 试图在错误的存储库(first_app.git)而不是新创建的存储库(demo_app.git)中提交。为什么会这样?
在尝试提交之前,我输入了以下内容:
$ cd ~/rails_projects
$ rails new demo_app
$ cd demo_app
然后编辑了我的 gem 文件,一切似乎都很好。直到我遇到这个 git 问题。有什么建议么?谢谢你。