使用 git 上传文件时,运行 命令 git pull origin 时未成功,出现报错信息

项目场景:

背景:

使用 git 上传文件时,运行 命令 git pull origin 时未成功,出现报错信息


问题描述

问题:

$ git pull origin print --allow-unrelated-histories
error: Pulling is not possible because you have unmerged files.
hint: Fix them up in the work tree, and then use 'git add/rm <file>'
hint: as appropriate to mark resolution and make a commit.
fatal: Exiting because of an unresolved conflict.


在这里插入图片描述


原因分析:

分析:

在这里插入图片描述


解决方案:

解决方案:
根据错误信息的提示,我们可以了解到,是有文件存在冲突,所以我们首先需要:

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

命令: git reset --hard FETCH_HEAD
在这里插入图片描述
二、add文件

命令: git add .

三、查看状态

命令:git status

四、重新提交文件

命令: git commit -m “new version”

五、从将本地的分支版本上传到远程并合并
git push

六、从远程获取 最新版本并 merge 到本地
git pull

示例: git pull origin master

七、git fetch 和 git pull 的区别:

git fetch:相当于是从远程获取最新版本到本地,不会自动合并。
git pull:相当于是从远程获取最新版本并 merge 到本地。

最近更新

  1. TCP协议是安全的吗?

    2024-02-07 14:50:02       18 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-02-07 14:50:02       19 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-02-07 14:50:02       18 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-02-07 14:50:02       20 阅读

热门阅读

  1. 2 进程(上)

    2024-02-07 14:50:02       32 阅读
  2. LeetCode树总结

    2024-02-07 14:50:02       36 阅读
  3. mysql order by 排序原理

    2024-02-07 14:50:02       25 阅读
  4. 每月AI科研动向(2024年1月)

    2024-02-07 14:50:02       28 阅读
  5. 如何快速上手Vue框架

    2024-02-07 14:50:02       33 阅读
  6. 解决 python CV2 imread读取中文文件名的问题

    2024-02-07 14:50:02       32 阅读
  7. 达梦数据库适配Springboot+MybatisPlus+达梦数据库

    2024-02-07 14:50:02       33 阅读
  8. 渗透测试工具库总结(全网最全)

    2024-02-07 14:50:02       52 阅读
  9. redis相关问题

    2024-02-07 14:50:02       28 阅读
  10. UI自动化之Poco常用断言方式

    2024-02-07 14:50:02       30 阅读
  11. 踩坑实录(Second Day)

    2024-02-07 14:50:02       26 阅读
  12. 蓝桥杯(Web大学组)2022国赛真题:新鲜的蔬菜

    2024-02-07 14:50:02       33 阅读
  13. 51单片机 温度传感器得数据,传到上位机

    2024-02-07 14:50:02       32 阅读
  14. docker学习

    2024-02-07 14:50:02       25 阅读