天天看點

git push -u origin master錯誤解決錯誤提示為:

git push -u orrgin master錯誤解決

  • 錯誤提示為:
    • 原因:
    • 解決方法:

錯誤提示為:

To github.com:PorterLi/myDataStructCode.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '[email protected]:PorterLi/myDataStructCode.git'
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.
           

原因:

遠端倉庫有本地沒有的檔案。即,兩個倉庫不同步,這種情況下需要利用git pull 指令合并兩個倉庫。
           

解決方法:

1.先利用git add 和git commit 将本地暫存區的内容添加到倉庫

2.git status 檢視本地倉庫内容,如下則可進行第三步

$ git status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean
           

3.指令如下,合并兩個倉庫。

git pull --rebase origin master