git报错:Pull is not possible because you have unmerged files解决方法

2019-07-11 11:26:21

在git pull的过程中,如果有冲突,那么除了冲突的文件之外,其它的文件都会做为staged区的文件保存起来。

$ git pull

A    Applications/Commerce/BookingAnalysis.java
A    Applications/Commerce/ClickSummaryFormatter.java
M    Applications/CommerceForecasting/forecast/Forecast.java
A    Applications/CommerceForecasting/forecast/ForecastCurveProviderCategory.java
M    Applications/CommerceForecasting/forecast/ForecastProvider.java
M    Applications/CommerceForecasting/forecast/InputPropertyItem.java
......

A    Applications/LocalezeImporter/com/tripadvisor/feeds/SingleMenuLocalezeMatcher.java
A    Applications/LocalezeImporter/com/tripadvisor/feeds/TypeCategory.java

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你会发现下面古怪的事情:

zhonghua@pts/ttys000 $ git status
# On branch sns
# Your branch and 'snsconnect/sns' have diverged,
# and have 1 and 52 different commit(s) each, respectively.
#
# Changes to be committed:
#
#    new file:   src/config/features_daodao.ini
#    new file:   src/config/services.xml
#    new file:   src/config/svnroot/hooks/mailer.conf
#    new file:   src/config/svnroot/hooks/mailer.py
#    new file:   src/config/svnroot/hooks/post-commit
#    new file:   src/config/svnroot/hooks/pre-commit
#    new file:   src/config/svnroot/hooks/prerelease_notifications.py
#    new file:   src/config/svnroot/hooks/run_checks.py
…….

# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#    _build/
#    css/combined/
#    css/gen/
#    daodao-site.patch
#    daodao-site.patch1
#    js/combined/
#    js/gen/
#    lib/weibo/
#    src/bin/

Pull is not possible because you have unmerged files.

本地的push和merge会形成MERGE-HEAD(FETCH-HEAD), HEAD(PUSH-HEAD)这样的引用。HEAD代表本地最近成功push后形成的引用。MERGE-HEAD表示成功pull后形成的引用。可以通过MERGE-HEAD或者HEAD来实现类型与svn revet的效果。

解决:

1.将本地的冲突文件冲掉,不仅需要reset到MERGE-HEAD或者HEAD,还需要--hard。没有后面的hard,不会冲掉本地工作区。只会冲掉stage区。

git reset --hard FETCH_HEAD

2.git pull就会成功。


  • 2019-07-24 01:21:15

    android开发无障碍app

    最近做一些为盲人提供服务的APP,还是挺有感触的,感谢手机和互联网的普及,他们的生活比以前丰富了很多。 通过读屏软件,盲人可以操作手机,上网浏览信息。读屏软件的工作原理很简单,就是读出屏幕上按钮、文本的信息。

  • 2019-07-26 19:31:03

    Guacamole搭建

    因项目需要,经历多天查阅各种文档,几经波折终于功德圆满,写下此篇文章供大家分享。Guacamole就个人理解而言是一个可以通过web浏览器访问远程服务器终端进行操作的可视化工具。主要由web(浏览器)、Guacamole Server(核心)、Remote Desktops(远程桌面)三大模块组成。

  • 2019-07-30 22:36:10

    使用 Spring Initializr 初始化 Spring Boot 项目

    万事开头难,你需要设置一个目录结构存放各种项目内容,创建构建文件,并在其中加入各 种依赖。Spring Boot CLI消除了不少设置工作,但如果你更倾向于传统Java项目结构,那你应该 看看Spring Initializr。

  • 2019-08-06 15:30:08

    小程序展示富文本

    然而rich-text有个问题,它不能够给内联img设置宽度100%,这样图片就容易溢出屏幕。我们只能在后台返回富文本的时候对图片的img标签进行格式化。或者前端进行格式化也行,我赞成使用后端,因为很多种情况我们不一定都能想得到。

  • 2019-08-07 09:07:32

    最全的Service Worker讲解

    Service Worker 最主要的特点是:在页面中注册并安装成功后,运行于浏览器后台,不受页面刷新的影响,可以监听和截拦作用域范围内所有页面的 HTTP 请求。 基于 Service Worker API 的特性,结合 Fetch API、Cache API、Push API、postMessage API 和 Notification API,可以在基于浏览器的 web 应用中实现如离线缓存、消息推送、静默更新等 native 应用常见的功能,以给 web 应用提供更好更丰富的使用体验。

  • 2019-08-07 09:09:19

    windows系统下定时关闭程序

    其中xxx.exe是你要关闭的进程中运行的exe,可以ctrl+alt+del打开任务管理器,进到详细信息查看 然后把.txt文件后缀改成.bat(此时要在查看一栏勾上文件拓展名,要不还是txt文档)