Git的commit your changes or stash them before you can merge
今天用git pull来更新代码,遇到了下面的问题:
error: Your local changes to the following files would be overwritten by merge:
xxx/xxx/xxx.java
Please, commit your changes or stash them before you can merge.
Aborting
但是服务器没有任何手动修改文件行为,很奇怪经常遇到莫名的这类问题
好吧,算啦,直接说最终的解决办法吧
1.stash
通常遇到这个问题,你可以直接commit你的修改;但我这次不想这样。
看看git stash是如何做的。
git stash
git pull
git stash pop
接下来diff一下此文件看看自动合并的情况,并作出相应修改。

git stash: 备份当前的工作区的内容,从最近的一次提交中读取相关内容,让工作区保证和上次提交的内容一致。同时,将当前的工作区内容保存到Git栈中。
git stash pop: 从Git栈中读取最近一次保存的内容,恢复工作区的相关内容。由于可能存在多个Stash的内容,所以用栈来管理,pop会从最近的一个stash中读取内容并恢复。
git stash list: 显示Git栈内的所有备份,可以利用这个列表来决定从那个地方恢复。
git stash clear: 清空Git栈。此时使用gitg等图形化工具会发现,原来stash的哪些节点都消失了。

2.放弃本地修改,直接覆盖之
git reset --hard
git pull
通常我直接采取方法2,这样不用考虑缓冲区的清理问题,这种更方便点吧
Git的commit your changes or stash them before you can merge的更多相关文章
- Git 解决方案 commit your changes or stash them before you can merge
error: Your local changes to the following files would be overwritten by merge: *********** Please, ...
- git pull冲突:commit your changes or stash them before you can merge.
今天用git pull来更新代码,遇到了下面的问题: error: Your local changes to the following files would be overwritten by ...
- Git冲突:commit your changes or stash them before you can merge.
用git pull来更新代码的时候,遇到了下面的问题: error: Your local changes to the following files would be overwritten by ...
- Git冲突:commit your changes or stash them before you can merge. 解决办法
用git pull来更新代码的时候,遇到了下面的问题: 1 2 3 4 error: Your local changes to the following files would be overwr ...
- Git出现error: Your local changes to the following files would be overwritten by merge: ... Please, commit your changes or stash them before you can merge.的问题解决(Git代码冲突)
在使用git pull拉取服务器最新版本时,如果出现error: Your local changes to the following files would be overwritten by m ...
- git pull和git merge区别&&Git冲突:commit your changes or stash them before you can merge. 解决办法
http://blog.csdn.net/sidely/article/details/40143441 原文: http://www.tech126.com/git-fetch-pull/ Git中 ...
- (转)Git冲突:commit your changes or stash them before you can merge. 解决办法
用git pull来更新代码的时候,遇到了下面的问题: error: Your local changes to the following files would be overwritten by ...
- Git提交代码冲突:commit your changes or stash them before you can merge.
用git pull拉取远程分支代码时候遇到如下问题: error: Your local changes to the following files would be overwritten by ...
- Git更新本地仓库及冲突"Commit your changes or stash them before you can merge"解决
Git中从远程的分支获取最新的版本到本地有这样2个命令: 1. git fetch:相当于是从远程获取最新版本到本地,不会自动merge git fetch origin mastergit log ...
随机推荐
- BufferedReaderTest
package JBJADV003;import java.io.*;public class BufferedReaderTest { /** * @param args */ public sta ...
- javascript的一个简易利率计算器+js图像显示 代码
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title> ...
- Django学习(三)---Models(ORM框架)
1) Django 中Models是与数据库相关的,与数据库相关的代码一般写在 models.py中,Django 支持 sqlite3, MySQL, PostgreSQL等数据库,只需要在sett ...
- python机器学习模块安装
环境:RHEL6.5 离线安装 ############################################################################ 一,本地yum ...
- JavaScript 之 HelloWorld编写
HelloWorld.html 代码如下: <html><body><script type="text/javascript">documen ...
- Android - 使用Volley请求网络数据
Android - 使用Volley请求网络数据 Android L : Android Studio 14 个人使用volley的小记,简述使用方法,不涉及volley源码 准备工作 导入Volle ...
- MySQL巧用自定义函数进行查询优化
用户自定义变量是一个很容易被遗忘的MySQL特性,但是用的好,发挥其潜力,在很多场景都可以写出非常高效的查询语句. 一. 实现一个按照actorid排序的列 mysql; Query OK, rows ...
- LInux挂载windows共享磁盘
#!/bin/sh #进行windows paths目录同步 cd /mnt str="//10.33.4.199/linux" result=$(df | grep ${str} ...
- python2.7 + selenium3.4.3浏览器的选择
大家都知道,selenium2对火狐浏览器兼容性比较好,和谷歌和IE相比,好处是无需安装相应的driver.exe来支持启动浏览器,但是缺点是最高支持火狐47版本. 现在selenium3出来了,是不 ...
- 阿里云服务器Windows Server 2008/2012部署Office Web Server 2013
以前成功将Office Web Server 2013部署在了本地服务器上,此次是将Office Web Server 2013部署在阿里云服务器Windows Server 2008和2012上,中 ...