天天看點

解決本地倉庫第一次上傳到github失敗failed to push some refs to github

在github上建立倉庫,在本地第一次執行push -u origin master 時,提示如下:

192:DetectFileEncoding Edward$ git push -u origin master
Warning: Permanently added the RSA host key for IP address '192.30.255.113' to the list of known hosts.
To github.com:Edward125/DetectFileEncoding.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '[email protected]:Edward125/DetectFileEncoding.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.
           

實際發現解決方法有兩種

1,根據提示,使用git pull,将github上的分支和本地的分支合并

2,直接使用push -f origin master 強制push。