zoukankan      html  css  js  c++  java
  • error: Your local changes to the following files would be overwritten by merge

    场景:在分支feature_A 切换到分支feature_B后,在分支feature_B上使用git pull ,出现如下报错.

    错误描述:

    error: Your local changes to the following files would be overwritten by merge:

    Please commit your changes or stash them before you merge.

    error: The following untracked working tree files would be overwritten by merge:

    Please move or remove them before you merge.

    Aborting
    Updating 5fa2f5a..0a8456f

     解决办法:

    第一个error,出现的原因是本地工作区有未提交到本地仓库的代码,并且与远程代码有冲突,如果git强制覆盖的你的代码话,会导致你本地代码丢失,所以出现这个提示。

    方法一:可以先stash本地代码,再pull ,再stash pop.   方法二:先commit本地代码,再解决冲突。

    第二个error,出现的原因是,一些不需要加到版本控制中的文件被加到了版本控制,比如.iml 等,这些文件本地每次都会改变,git pull的时候肯定会与服务器上的冲突。

    方法一:直接用服务的版本覆盖自己本地的。git reset --hard HEAD 。方法二:将这些不需要版本控制的文件从版本库中删掉。(推荐)

  • 相关阅读:
    mysql自增长字段设置
    查看docker的挂载目录
    centos rpm安装jdk1.8
    mybatis-地区三表生成地区树
    post表单、json接口
    git子模块使用
    解决Windows系统80端口被占用
    交换机基础命令
    JMX协议
    WMI协议
  • 原文地址:https://www.cnblogs.com/john123/p/11517737.html
Copyright © 2011-2022 走看看