Git教程:! [rejected]        master -> master (fetch first)解決辦法

在github上修改過readme.md後,在本地執行git push origin master後會提示:

$ git push origin master
To github.com:taozhuowei/StoreMyToys.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to '[email protected]:taozhuowei/StoreMyToys.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 --rebase origin master 將github修改的文件更新到本地

$ git pull --rebase origin master
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (20/20), done.
remote: Compressing objects: 100% (17/17), done.
remote: Total 17 (delta 4), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (17/17), 3.99 KiB | 5.00 KiB/s, done.
From github.com:taozhuowei/StoreMyToys
 * branch            master     -> FETCH_HEAD
   5afe506..b843c89  master     -> origin/master
First, rewinding head to replay your work on top of it...
Applying: commit Vue to-do
 

再次提交:git push origin master

$ git push origin master
Enumerating objects: 26, done.
Counting objects: 100% (26/26), done.
Delta compression using up to 8 threads
Compressing objects: 100% (22/22), done.
Writing objects: 100% (25/25), 49.42 KiB | 153.00 KiB/s, done.
Total 25 (delta 0), reused 0 (delta 0)
To github.com:taozhuowei/StoreMyToys.git
   b843c89..bc04ef1  master -> master
 

提交成功

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章