当前位置: 首页 > news >正文

【Git】Please commit your changes or stash them before you merge的解决方法

背景

我从远程库中clone了一个项目进行开发,修改了一部分代码后,远程库有更新,我想将远程更新拉取下来,并且保留自己的更改,使用git pull origin master命令,有报错:

error: Your local changes to the following files would be overwritten by merge:xxx/xxx/api.pyxxx/xxx/settings.pyxxx/package.json
Please commit your changes or stash them before you merge.
Aborting
Updating 58b3d95..c5b6724

解决方法

使用git stash

官方的介绍
Often, when you’ve been working on part of your project, things are in a messy state and you want to switch branches for a bit to work on something else. The problem is, you don’t want to do a commit of half-done work just so you can get back to this point later. The answer to this issue is the command.git stash
Stashing takes the dirty state of your working directory — that is, your modified tracked files and staged changes — and saves it on a stack of unfinished changes that you can reapply at any time (even on a different branch).
通常,当您处理项目的一部分时,事情处于混乱状态,您希望切换分支以处理其他事情。 问题是,你不想做一个半成品的工作提交,以便稍后可以回到这一点。 这个问题的答案是命令。git stash
存储获取工作目录的脏状态(即修改的跟踪文件和暂存更改),并将其保存在一堆未完成的更改中,您可以随时重新应用这些更改(甚至在不同的分支上)。

步骤如下:

要将新的存储推送到堆栈上
> git stash
Saved working directory and index state WIP on master: 58b3d95 修改README文件
把远程仓库的更新拉到本地仓库中
> git pull
把刚才存储推送到堆栈上的代码更新到本地
> git stash pop

参考链接

http://www.lryc.cn/news/96068.html

相关文章:

  • 网卡收发包系统结构收发包流程,tcp/ip协议,socket套接字缓冲区,滑动窗口,mtu/mss
  • VUE之axios使用,跨域问题,拦截器添加Token
  • 阿里云函数计算签名认证(iOS实现细节备注)
  • 成都爱尔蔡裕:泡在“糖”里的脆弱血管,暴露在眼睛深处
  • 神经网络小记-过拟合与欠拟合
  • 外贸行业企业邮箱选择:安全好用的邮箱服务
  • flutter开发实战-RepaintBoundary实现Widget截图功能
  • vue中路由懒加载的写法
  • 【Spring MVC】小文件上传的多种方法
  • UE5.1移动端PreintegratedSkinBxDF解析
  • WebSocket心跳机制(笔记大全)
  • Spring Boot日志:SLF4J和Logback
  • [C++] C++入门第二篇 -- 引用 -- 内联函数inline -- auto+for
  • Latex | 将MATLAB图并导入Latex中的方法
  • JSON格式Python,Java,PHP等封装根据关键词搜索获取淘宝商品列表数据API
  • MySQL MHA高可用配置及故障切换
  • PHP8知识详解:PHP8开发工具VS Code的安装
  • Sui Move与标准Move的有哪些区别和根本性创新
  • 构建自己的ChatGPT:从零开始构建个性化语言模型
  • 【react】react18的学习(十二)– 底层原理(二)之 迭代器 iterator
  • 一遍过JavaSE基础知识
  • 【云原生】Kubernetes之ConfigMap
  • 8.python设计模式【组合模式】
  • tkinter制作任意图形窗口
  • 视频监控综合管理平台EasyCVR多分屏默认播放协议的配置优化
  • 2023杭电多校第三场 1012.Noblesse Code
  • ubuntu qt 环境变量配置
  • 按照Vue写WPF(0):功能实现
  • vb+ACCESS教师管理系统设计设计与实现
  • C++笔记之对指针类型的变量进行+1操作