我在邁克爾·哈特爾的Ruby on Rails的教程第2章,我鍵入以下到命令行:爲什麼Git提交到錯誤的存儲庫?
$ 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
,然後編輯我的寶石文件,一切似乎都很好。直到我遇到這個git問題。有什麼建議麼?謝謝。
我只是試過,'$ git remote -v',它看起來像我也有一個github的demo_app.git ...這裏是輸出:'github [email protected]:themaktravels/demo_app.git(fetch )''github \t [email protected]:themaktravels/demo_app.git(push)''origin \t [email protected]:(fetch)''origin [email protected]:(push)'。這是否意味着在我創建新的回購之前,我必須將「github」重命名爲其他內容? – LearningHowToCode