如何解決git上傳檔案出錯[rejected] master -> master (fetch first) error: failed to push some refs to '
阿新 • • 發佈:2018-12-10
使用Git上傳本地檔案到github時,一直報錯,這個問題也困擾了我2天,終於被解決。
git add .
git commit -m"peTzxz"
git push origin master
當執行到push時,就會報錯,報錯程式碼如下:
MacBook-Pro:資料庫課程設計 Pett$ git push origin master
To github.com:peTzxz/Property-management-system
! [rejected] master -> master (fetch first)
error: failed to push some refs to '[email protected]:peTzxz/Property-management-system'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...' ) before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
出現這個問題是因為github中的README.md檔案不在原生代碼目錄中,可以通過如下命令進行程式碼合併
git pull --rebase origin master
然後再
git push origin master
便可上傳成功
這樣就可以在github插上我們上傳的檔案啦!