前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >git报错:Pull is not possible because you have unmerged files解决方法

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

原创
作者头像
星哥玩云
发布2022-06-18 16:49:43
2.3K0
发布2022-06-18 16:49:43
举报
文章被收录于专栏:开源部署

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

开发提交git pull报错

代码语言:txt
复制
Your branch and 'origin/online' have diverged,
and have 12 and 1 different commit each, respectively.
  (use "git pull" to merge the remote branch into yours)
Auto-merging api/Tpl/Template_api/recharge_coin.html
CONFLICT (content): Merge conflict in api/Tpl/Template_api/recharge_coin.html
Automatic merge failed; fix conflicts and then commit the result.
error: you need to resolve your current index first
api/Tpl/Template_api/recharge_coin.html: needs merge
Build step 'Execute shell' marked build as failure
Finished: FAILURE

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

git reset --hard FETCH_HEAD

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

这个需谨慎,最好先备份,我搞过一次就是刚做的啥也没啦

修复操作

代码语言:txt
复制
$ git status
# On branch online
# Your branch and 'origin/online' have diverged,
# and have 12 and 2 different commits 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:      api/Tpl/Template_api/recharge_coin.html
#
# Changes not staged for commit:
#   (use "git add/rm <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       deleted:    api/Conf/api/7477.ucconfig-sample.php
#       deleted:    api/Conf/config-sample.php
#       deleted:    api/Conf/dbconfig.inc-sample.php
#
no changes added to commit (use "git add" and/or "git commit -a")
$ git reset --hard FETCH_HEAD
HEAD is now at 5d2bfb0 调试
$ git pull
Already up-to-date.
$ ll api/Tpl/Template_api/recharge_coin.html
-rw-rw-r-- 1 www www 8484 Dec 23 21:11 api/Tpl/Template_api/recharge_coin.html

$ git status
# On branch master
nothing to commit, working directory clean

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • git报错:Pull is not possible because you have unmerged files解决方法
    • 开发提交git pull报错
      • 修复操作
      领券
      问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档