Git - 错误集

错误1:fatal: refusing to merge unrelated histories

$ git pull 20221109test master
From https://gitee.com/chaung_sun/20221109test
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

$ git merge 20221109test/master
fatal: refusing to merge unrelated histories


===========> 解决:
$ git pull 20221109test master --allow-unrelated-histories

错误2:开发完项目初始化本地仓库后,第一次推送出现:Updates were rejected because the tip of your current branch is behind

$ git push origin master
To https://gitee.com/chaung_sun/douban.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/chaung_sun/douban.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.


# 加上--rebase参数解决问题 或者 强制拉取 git push origin master -f

86158@DESKTOP-9PANV23 MINGW64 /e/PyProject/douban (master)
$ git pull origin master --rebase
From https://gitee.com/chaung_sun/douban
 * branch            master     -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Applying: add douban

--rebase的作用:
1.https://blog.csdn.net/yao_hou/article/details/108178717
2.https://blog.csdn.net/TomorrowAndTuture/article/details/107677939?spm=1001.2101.3001.6661.1&utm_medium=distribute.pc_relevant_t0.none-task-blog-2~default~CTRLIST~Rate-1-107677939-blog-108178717.pc_relevant_landingrelevant&depth_1-utm_source=distribute.pc_relevant_t0.none-task-blog-2~default~CTRLIST~Rate-1-107677939-blog-108178717.pc_relevant_landingrelevant&utm_relevant_index=1

posted @ 2022-11-09 23:14  chuangzhou  阅读(36)  评论(0)    收藏  举报