! [rejected] master -> master (fetch first) error: failed to push some refs to 'git@github.com:wq-9/test.git'


https://www.cnblogs.com/bigtreei/p/10180383.html

 

今天對代碼進行了修改優化,然后往往遠程push,但push后報錯了


git操作

git add .
git commit -m"fix"
git push origin master:dev-gaochao
 

報錯信息

復制代碼
To https://amc-msra.visualstudio.com/trading-algo/_git/real-trading
 ! [rejected]        master -> dev-gaochao (fetch first)
error: failed to push some refs to 'https://amc-msra.visualstudio.com/trading-algo/_git/real-trading'
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.
復制代碼
 

原因

之所以出現這個原因,是因為我在線上生成、編輯了README.md文件,而本地代碼文件中不包含它,所以線上線下就對不上了。

 

解決

將線上、線下代碼進行合並

git pull --rebase origin dev-gaochao

然后再進行push

git push origin master:dev-gaochao

成功:

復制代碼
Enumerating objects: 11, done.
Counting objects: 100% (11/11), done.
Delta compression using up to 4 threads
Compressing objects: 100% (7/7), done.
Writing objects: 100% (7/7), 1.90 KiB | 487.00 KiB/s, done.
Total 7 (delta 4), reused 0 (delta 0)
remote: Analyzing objects... (7/7) (13 ms)
remote: Checking for credentials and other secrets... (1/1) done (1008 ms)
remote: Storing packfile... done (157 ms)
remote: Storing index... done (87 ms)
To https://amc-msra.visualstudio.com/trading-algo/_git/real-trading
   1919525..6f3asa4dd6  master -> dev-gaochao
復制代碼


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM