日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【Git】pull 分支报错 fatal: Need to specify how to reconcile divergent branches...

發布時間:2023/12/16 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【Git】pull 分支报错 fatal: Need to specify how to reconcile divergent branches... 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

文章目錄

    • 報錯消息
    • 解決方法

報錯消息

  • 示例圖:

  • 示例代碼:
? fisher git:(test) git pull origin test From git.woa.com:wxg-bigdata/fisher* branch test -> FETCH_HEAD hint: You have divergent branches and need to specify how to reconcile them. hint: You can do so by running one of the following commands sometime before hint: your next pull: hint: hint: git config pull.rebase false # merge (the default strategy) hint: git config pull.rebase true # rebase hint: git config pull.ff only # fast-forward only hint: hint: You can replace "git config" with "git config --global" to set a default hint: preference for all repositories. You can also pass --rebase, --no-rebase, hint: or --ff-only on the command line to override the configured default per hint: invocation. fatal: Need to specify how to reconcile divergent branches.
  • 翻譯:
?fisher git:(test) git pull origin test 從git.woa.com: wxg-bigdata /費舍爾 *分支測試->FETCH_HEAD 提示:您有不同的分支,需要指定如何協調它們。 提示:您可以通過在之前某個時間運行以下命令之一來做到這一點 提示:你的下一招: 提示: 提示:git config pull.rebase false # 合并(默認策略) 提示:git config pull.rebase true # Rebase 提示:git config pull.ff only # 僅快進 提示: 提示:可以將“git config”替換為“git config——global”來設置默認值 提示:首選所有存儲庫。你也可以傳遞——rebase,——no-rebase, 提示:或命令行上的——ff-only,以覆蓋配置的默認per 提示:調用。 fatal:需要指定如何協調不同的分支。

解決方法

分析:這是由于你拉取pull分支前,進行過merge合并更新分支操作,而其他人在你之前已經push過一個版本,導致版本不一致

第一種解決方法:比較簡單

  • 執行git config pull.rebase false
  • 默認將pull下來的代碼與現有改動的代碼進行合并
  • 但是可能會造成代碼沖突,需要處理下這個問題,代碼沖突如果2個人都改了同一個文件,需要聯系之前push的同學,看看這塊代碼怎么保存

第二種解決方法:回退到合并之前的代碼,在進行pull拉取最新代碼

注意:這種解決方法僅適用于2個分支之間的合并(git merge)操作,比如你是將dev開發分支合并到test分支之前沒pull,那這時候test分支需要回退到未合并前的版本。
test上合并上去的代碼將會丟失,等你test分支能成功pull后,需要重新合并(merge)開發分支dev上的代碼合并到test上。所以記得保留dev開發分支這個版本的代碼再把test回退到上一個版本,等pull成功,再重新在test分支上合并dev分支代碼

  • 查看最近3次提交的歷史版本
? fisher git:(test) git log -3 # 查看最近3次提交的歷史版本 commit da20b931f4e04a61f0f9b4e4726a2e907e566fc9 (HEAD -> test) Merge: 33df706e 6018c237 Author: v_isiliu <v_isiliu@tencent.com> Date: Wed Jan 19 09:58:40 2022 +0800Merge branch 'feture/tapd#870810123' into testcommit 6018c237278f5265e78314049d6642e493ebdb5e (feture/tapd#870810123) Author: v_isiliu <v_isiliu@tencent.com> Date: Wed Jan 19 09:57:50 2022 +0800feat: 發布版本'feture/tapd#870810123'commit 33df706e780d10af6435bda1fee85430604eebfc Merge: 1d06cd1f 7589979d Author: v_isiliu <v_isiliu@tencent.com> Date: Tue Jan 18 16:11:21 2022 +0800Merge branch 'feature/date#0118' into test
  • 根據歷史版本記錄,選擇commit地址,回退到自己合并之前的版本
? fisher git:(test) git reset --hard 33df706e780d10af6435bda1fee85430604eebfc HEAD is now at 33df706e Merge branch 'feature/date#0118' into test
  • 再進行pull更新分支
? fisher git:(test) git pull origin test
  • 最后再重新合并代碼
? fisher git:(test) git merge dev

記得養成一個良好git發布流程的習慣

# 分支合并發布流程: git add . # 將所有新增、修改或刪除的文件添加到暫存區 git commit -m "版本發布" # 將暫存區的文件發版 git status # 查看是否還有文件沒有發布上去 git checkout test # 切換到要合并的分支 git pull # 在test 分支上拉取最新代碼,避免沖突 git merge dev # 在test 分支上合并 dev 分支上的代碼 git push # 上傳test分支代碼

更多git操作請查看博主的另一篇文章,關注我不迷路,我替你們把坑都踩平了:

https://blog.csdn.net/qq_45677671/article/details/114594940?spm=1001.2014.3001.5502

總結

以上是生活随笔為你收集整理的【Git】pull 分支报错 fatal: Need to specify how to reconcile divergent branches...的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。