• git冲突解决


    您是否有遇到类似下面的的git冲突提示、有的话、让我们一起来看看是怎么产生这样的问题的!
    Pull is not possible because you have unmerged files.
    Please, fix them up in the work tree, and then use 'git add/rm <file>'

    一、首先创建一个测试库、和测试clone库

    test $ mkdir repo && cd repo && git init && touch file && git add file && git commit -m "msg"
    repo $ cd .. && git clone repo repo_clone && cd repo_clone
    repo_clone $ echo "text2" >> file && git add file && git commit -m "msg" && cd ../repo
    repo $ echo "text1" >> file && git add file && git commit -m "msg" && cd ../repo_clone

    二、现在在repo_clone执行git pull就会报conflicts

    repo_clone $ git pull origin master
    remote: Counting objects: 5, done.
    remote: Total 3 (delta 0), reused 0 (delta 0)
    Unpacking objects: 100% (3/3), done.
    From /home/anshulgoyal/Desktop/test/test/repo
     * branch            master     -> FETCH_HEAD
       24d5b2e..1a1aa70  master     -> origin/master
    Auto-merging file
    CONFLICT (content): Merge conflict in file
    Automatic merge failed; fix conflicts and then commit the result.

    三、如果我们忽略这个冲突不去解决它、而远端origin还在执行commit

    repo_clone $ cd ../repo
    repo $ echo "text1" >> file && git add file && git commit -m "msg" && cd ../repo_clone

    四、此时我们再来执行clone库里面的git pull、就会得到我们遇到的问题。

    repo_clone $ git pull
    U   file
    Pull is not possible because you have unmerged files.
    Please, fix them up in the work tree, and then use 'git add/rm <file>'
    as appropriate to mark resolution, or use 'git commit -a'.

    五、此时我们执行git status就可以清晰的看到未处理的冲突问题。

    repo_clone $ git status
    On branch master
    Your branch and 'origin/master' have diverged,
    and have 1 and 1 different commit each, respectively.
      (use "git pull" to merge the remote branch into yours)
    
    You have unmerged paths.
      (fix conflicts and run "git commit")
    
    Unmerged paths:
      (use "git add <file>..." to mark resolution)
    
            both modified:      file

    六、所以要解决这个问题、我们就需要解决之前遇到的冲突而没有解决掉得问题。

    vi file 把里面的冲突解决掉、让后重新提交file

    repo_clone $ git add file && git commit -m "resolved merge conflicts"
    [master 39c3ba1] resolved merge conflicts

    问题解决。

  • 相关阅读:
    国税开发子系统----纳税服务子系统问题
    Hibernate中的一对一多映射和一对一映射的创建
    hibernate 创建一对一唯一外键映射的问题
    疑问,TESt中注入sessionFactory失败
    AJAX方式进行验证码的判断(JS方式)
    过滤器和拦截器的使用
    SSH框架的整合
    编码问题
    微服务架构对比
    docker安装mysql8.0连接问题,sqlyog报2058或者Navicat 1257
  • 原文地址:https://www.cnblogs.com/miaoshiqian/p/4431580.html
Copyright © 2020-2023  润新知