[英]non-fast-forward error in git
我想在現有項目中使用git ,因此我在github上為其創建了一個空間,並在主機的項目文件夾中按常規進行了操作:
$ git config --global user.name myname
$ git config --global user.email "myemail@email.com"
$ cd myProjectFolder/
$ git init
$ git add .
$ git commit -m "first commit"
$ git remote add origin https://github.com/myusername/myprojectname.git
然后,我希望項目的所有文件也都位於在線存儲庫中:
$ git push origin master
但是我遇到了以下令人恐懼的錯誤:
To https://github.com/myusername/myprojectname.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/myusername/myprojectname.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.
現在,我沒有什么要從在線存儲庫中pull
的,因為那邊仍然沒有東西。 我為什么要拉?
無論如何,我該怎么做才能使我的所有文件聯機並開始使用git?
在git remote add
之后,您已經知道teh remote repo的URL,但尚不知道其內容。
在git fetch origin
(或git pull
)之后,您將能夠git push
因為這樣遠程遠程倉庫的內容就會被知道。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.