• Your local changes to the following files would be overwritten by merge: ... Please, commit your changes or stash them before you can merge


    Git出现error: Your local changes to the following files would be overwritten by merge: ... Please, commit your changes or stash them before you can merge.的问题解决(Git代码冲突)

    在使用git pull拉取服务器最新版本时,如果出现error: Your local changes to the following files would be overwritten by merge: ... Please, commit your changes or stash them before you can merge.错误时,代表这代码冲突了,本地修改了代码导致无法覆盖服务器上的。

    此时有如下解决方法:

    注意:在做所有操作前,切记要先备份本地代码。

    1、如果希望保留生产服务器上所做的改动,仅仅并入新配置项, 处理方法如下:

    git stash
    git pull
    git stash pop

    然后可以使用Git diff -w +文件名来确认代码自动合并的情况。

    2、如果要直接使用服务器上最新版本,那么可以选择直接覆盖

    git reset --hard
    git pull

    其中git reset是针对版本。

    http://blog.csdn.net/misakaqunianxiatian/article/details/51103734

    ##############################

    方法1:如果你想保留刚才本地修改的代码,并把git服务器上的代码pull到本地(本地刚才修改的代码将会被暂时封存起来)

    git stash  
    git pull origin master  
    git stash pop

    如此一来,服务器上的代码更新到了本地,而且你本地修改的代码也没有被覆盖,之后使用add,commit,push 命令即可更新本地代码到服务器了。

    方法2、如果你想完全地覆盖本地的代码,只保留服务器端代码,则直接回退到上一个版本,再进行pull

    git reset --hard
    git pull origin master
  • 相关阅读:
    Codeforces 67A【模拟】
    Codeforces325 D【并查集维护连通性】
    CodeForces 363D 【二分+贪心】
    Lightoj1084【DP啊DP】
    lightoj1062【几何(二分)】
    lightoj1066【BFS】
    lightoj1064 【DP求方案】
    lightoj1063【求割点】
    lightoj 1074【spfa判负环】
    CodeForces 382C【模拟】
  • 原文地址:https://www.cnblogs.com/linkenpark/p/8601203.html
Copyright © 2020-2023  润新知