首页   >   代码编程

git pull提示“The following untracked working tree files would be overwritten by merge”

同事在创建项目的时候,忘记加.gitignore文件了,导致其他同事更新之后,再次提交代码时,提交了很多idea的配置文件,然后其他人更新下来了之后,导致pull不了代码,每次pull的时候就报错“error: The following untracked working tree files would be overwritten by merge: Aborting”。

多余的内容,截图如下:

git pull提示“The following untracked working tree files would be overwritten by merge”

详细错误信息如下:

felixdeMacBook-Pro:ifinance-koperasi felix$ git pull
Updating 584911b..ad962f7
error: The following untracked working tree files would be overwritten by merge:
        .idea/compiler.xml
        .idea/encodings.xml
        .idea/libraries/Maven__antlr_antlr_2_7_7.xml
        .idea/libraries/Maven__aopalliance_aopalliance_1_0.xml
        .idea/libraries/Maven__ch_qos_logback_logback_classic_1_1_11.xml
        .idea/libraries/Maven__ch_qos_logback_logback_core_1_1_11.xml
        .idea/libraries/Maven__classworlds_classworlds_1_1.xml
        .idea/libraries/Maven__cn_hutool_hutool_all_4_1_14.xml
        .idea/libraries/Maven__com_alibaba_fastjson_1_2_33.xml
        .idea/libraries/Maven__com_carrotsearch_hppc_0_7_1.xml
        .idea/libraries/Maven__com_caucho_hessian_4_0_51.xml
        .idea/libraries/Maven__com_digitalbertahan_commongroup_digitalbertahan_service_common_1_0_0_20181030_RELEASE.xml
        .idea/libraries/Maven__com_fasterxml_classmate_1_3_4.xml
        .idea/libraries/Maven__com_fasterxml_jackson_core_jackson_annotations_2_8_0.xml
        .idea/libraries/Maven__com_fasterxml_jackson_core_jackson_core_2_8_10.xml
        .idea/libraries/Maven__com_fasterxml_jackson_core_jackson_databind_2_8_10.xml
        .idea/libraries/Maven__com_fasterxml_jackson_dataformat_jackson_dataformat_yaml_2_8_10.xml
        .idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_hibernate5_2_8_10.xml
        .idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_hppc_2_8_10.xml
        .idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_json_org_2_8_10.xml
        .idea/libraries/Maven__com_fasterxml_jackson_datatype_jackson_datatype_jsr310_2_8_10.xml
        .idea/libraries/Maven__com_fasterxml_jackson_module_jackson_module_afterburner_2_8_10.xml
        .idea/libraries/Maven__com_github_jsqlparser_jsqlparser_1_0.xml
        .idea/libraries/Maven__com_github_pagehelper_pagehelper_5_1_4.xml
        .idea/libraries/Maven__com_github_ulisesbocchio_jasypt_spring_boot_2_0_0.xml
        .idea/libraries/Maven__com_github_ulisesbocchio_jasypt_spring_boot_starter_2_0_0.xml
        .idea/libraries/Maven__com_github_virtuald_curvesapi_1_05.xml
        .idea/libraries/Maven__com_google_code_findbugs_jsr305_3_0_2.xml
        .idea/libraries/Maven__com_google_code_gson_gson_2_8_2.xml
        .idea/libraries/Maven__com_google_gag_gag_1_0_1.xml
        .idea/libraries/Maven__com_google_guava_guava_18_0.xml
        .idea/libraries/Maven__com_google_inject_guice_4_1_0.xml
        .idea/libraries/Maven__com_jayway_jsonpath_json_path_2_2_0.xml
        .idea/libraries/Maven__com_netflix_archaius_archaius_core_0_7_4.xml
        .idea/libraries/Maven__com_netflix_eureka_eureka_client_1_7_0.xml
        .idea/libraries/Maven__com_netflix_eureka_eureka_core_1_7_0.xml
        .idea/libraries/Maven__com_netflix_hystrix_hystrix_core_1_5_12.xml
        .idea/libraries/Maven__com_netflix_hystrix_hystrix_javanica_1_5_12.xml
        .idea/libraries/Maven__com_netflix_hystrix_hystrix_metrics_event_stream_1_5_12.xml
        .idea/libraries/Maven__com_netflix_hystrix_hystrix_serialization_1_5_12.xml
        .idea/libraries/Maven__com_netflix_netflix_commons_netflix_commons_util_0_1_1.xml
        .idea/libraries/Maven__com_netflix_netflix_commons_netflix_eventbus_0_3_0.xml
        .idea/libraries/Maven__com_netflix_netflix_commons_netflix_infix_0_3_0.xml
        .idea/libraries/Maven__com_netflix_netflix_commons_netflix_statistics_0_1_1.xml
        .idea/libraries/Maven__com_netflix_ribbon_ribbon_2_2_4.xml
        .idea/libraries/Maven__com_netflix_ribbon_ribbon_core_2_2_4.xml
        .idea/libraries/Maven__com_netflix_ribbon_ribbon_eureka_2_2_4.xml
        .idea/libraries/Maven__com_netflix_ribbon_ribbon_httpclient_2_2_4.xml
        .idea/libraries/Maven__com_netflix_ribbon_ribbon_loadbalancer_2_2_4.xml
        .idea/libraries/Maven__com_netflix_ribbon_ribbon_transport_2_2_4.xml
        .idea/libraries/Maven__com_netflix_servo_servo_core_0_10_1.xml
        .idea/libraries/Maven__com_netflix_servo_servo_internal_0_10_1.xml
        .idea/libraries/Maven__com_netflix_spectator_spectator_api_0_30_0.xml
        .idea/libraries/Maven__com_netflix_spectator_spectator_reg_servo_0_30_0.xml
        .idea/libraries/Maven__com_restfb_restfb_1_6_16.xml
        .idea/libraries/Maven__com_sendgrid_java_http_client_2_3_4.xml
        .idea/libraries/Maven__com_sendgrid_sendgrid_java_3_1_0.xml
        .idea/libraries/Maven__com_sensorsdata_analytics_javasdk_SensorsAnalyticsSDK_3_1_0.xml
        .idea/libraries/Maven__com_
Aborting

由于直接回滚代码的代价过大,所以不敢使用reset来解决,又去尝试了git stash,但是提示本地无任何冲突,没有改变的地方需要stash,后来有一个同事将本地项目还原到最干净的版本,合并了最新分支以后,再次提交到git,此时他的机器上一切正常,但是其他同事更新了之后,竟然再一次出现了问题,后来发现,只要是用idea重新拉取代码就会有问题,真的是折腾死人了。。。

总结一下解决方案:

1、直接reset到历史版本(需要考虑代码改动量);

2、直接让管理员在版本库中删除(最简单);

3、将本地代码中的多余文件删除,然后在cmd工具中使用git命令更新代码;

QQ群: 686430774  /  718410762

站长Q: 1347384268

如果文章有帮到你,可以考虑请博主喝杯咖啡!

分享到:

欢迎分享本文,转载请注明出处!

作者:不忘初心

发布时间:2019-04-06

永久地址:https://www.jiweichengzhu.com/article/dced75aa436241f8b568eed62a34ebc8

评论