日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

git項目初次push提示error: failed to push some refs to https://gitee.com/xxxx/xxx.git’解決方案

作者:低調波 更新時間: 2022-04-11 編程語言

在本地與遠程新建倉庫并關聯后,初次push可能會遇到以下問題

  1. $ git push -u origin master
  2. To https://gitee.com/xxxx/xxx.git
  3. ! [rejected] master -> master (fetch first)
  4. error: failed to push some refs to 'https://gitee.com/xxxx/gittest.git'
  5. hint: Updates were rejected because the remote contains work that you do
  6. hint: not have locally. This is usually caused by another repository pushing
  7. hint: to the same ref. You may want to first integrate the remote changes
  8. hint: (e.g., 'git pull ...') before pushing again.
  9. hint: See the 'Note about fast-forwards' in 'git push --help' for details.

原因是因為遠程倉庫有一些文件而本地沒有,通常是在遠程建立倉庫時有一些初始化文件比如Readme License 等,并且直接pull會提示warning: no common commits,對于此類問題可以采用兩種解決辦法

1.git push -f 強制將本地文件推送至遠程,這樣會將遠程倉庫的已有的文件清掉

2. git pull origin master –allow-unrelated-histories 使用此命令告訴 git 允許不相關歷史合并 這樣就能把遠程文件拉取回來。執行此命令后會有一個提示,要求說明為何要講兩個不相關的分支合并,輸入信息后保存即可。

拉取完不同的文件之后再執行git push -u origin master命令即可push成功。

原文鏈接:https://blog.csdn.net/aaa58962458/article/details/119931603

欄目分類
最近更新