zoukankan      html  css  js  c++  java
  • Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists).

    Git fetch和git pull的区别, 解决Git报错:error: You have not concluded your merge (MERGE_HEAD exists).

    Git fetch和git pull的区别:

    都可以从远程获取最新版本到本地

    1.Git fetch:只是从远程获取最新版本到本地,不会merge(合并)

    $:git fetch origin master   //从远程的origin的master主分支上获取最新版本到origin/master分支上
    $:git log -p master..origin/master //比较本地的master分支和origin/master分支的区别
    $:git merge origin/master          //合并

    2.Git fetch:从远程获取最新版本并merge(合并)到本地

    $:git pull origin master  //相当于进行了 git fetch 和 git merge两部操作

    实际工作中,可能git fetch更好一些, 因为在merge前,可以根据实际情况决定是否merge


    再说导致报错:error: You have not concluded your merge (MERGE_HEAD exists).的原因可能是在以前pull下来的代码自动合并失败

    解决办法一:保留本地的更改,中止合并->重新合并->重新拉取

    $:git merge --abort
    $:git reset --merge
    $:git pull

    解决办法二:舍弃本地代码,远端版本覆盖本地版本(慎重)

    $:git fetch --all
    $:git reset --hard origin/master
    $:git fetch
  • 相关阅读:
    @RequestParam和@PathVariable用法小结
    Spring 的监听事件 ApplicationListener 和 ApplicationEvent 用法
    allator 对springBoot进行加密
    commons-lang3相关类实例
    JSP自定义标签
    Netty的简单Demo
    Spring-AOP为类增加新的功能
    深入理解abstract class和interface
    linux的基本操作
    GitHub从小白到熟悉<二>
  • 原文地址:https://www.cnblogs.com/sunnie-cc/p/8085730.html
Copyright © 2011-2022 走看看