問題描述
在執(zhí)行 git pull
時(shí),出現(xiàn)了如下提示:
? git:(test) git pull origin develop
* branch develop -> 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.
原因分析:
先翻譯下提示的信息:
git:(develop) git pull origin develop
提示:您有不同的分支,需要指定如何協(xié)調(diào)它們。
提示:您可以通過在之前某個(gè)時(shí)間運(yùn)行以下命令之一來做到這一點(diǎn)
提示:你的下一次獲取:
提示:
提示:git config pull.rebase false # 合并(默認(rèn)策略)
提示:git config pull.rebase true # Rebase
提示:git config pull.ff only # 僅快進(jìn)
提示:
提示:可以將“git config”替換為“git config——global”來設(shè)置默認(rèn)值
提示:首選所有存儲庫。你也可以傳遞——rebase,——no-rebase,
提示:或命令行上的——ff-only,以覆蓋配置的默認(rèn)per
提示:調(diào)用。
fatal:需要指定如何協(xié)調(diào)不同的分支。文章來源:http://www.zghlxwxcb.cn/news/detail-851090.html
原因:因?yàn)槟阍?code>pull代碼之前,進(jìn)行了merge
并更新代碼的操作,而其他人在你之前提交了一個(gè)版本,導(dǎo)致版本不一致。文章來源地址http://www.zghlxwxcb.cn/news/detail-851090.html
解決方案:
- 方案一:
- 按照提示,直接執(zhí)行
git config pull.rebase false
- 該操作是默認(rèn)獲取最新代碼,并與本地合并,如果有沖突,需要解決沖突。
- 按照提示,直接執(zhí)行
- 方案二:
- 該方法適用于兩個(gè)分支的合并
- 先保存下修改內(nèi)容,然后將當(dāng)前分支回退到修改代碼之前的版本,執(zhí)行
pull
以獲取最新代碼 - 然后將要合并的分支合并到當(dāng)前分支,再將自己的改動添加上,
- 最后再提交代碼
到了這里,關(guān)于【Git】Git pull代碼時(shí),出現(xiàn)報(bào)錯(cuò):hint: you have divergent branches and need to specify how to reconcile them.的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!