error: Your local changes to the following files would be overwritten by merge: stats.json

刘超 6天前 ⋅ 103 阅读   编辑

一、描述

  执行git pull,报如下错误

[/Workspace/Learn/dq]$ git pull                                                                                                                                                                        *[master] 
Updating eec0e01..bcdd512
error: Your local changes to the following files would be overwritten by merge:
	stats.json

二、分析

  1、增加--include-untracked参数,git stash save  --include-untracked stats.json,还是不行,如下

[/Workspace/Learn/dq]$ git stash save --include-untracked stats.json                                                                                [master] 
No local changes to save
[/Workspace/Learn/dq]$ git pull                                                                                                                     [master] 
Updating 38d6e78..fba0144
error: Your local changes to the following files would be overwritten by merge:
	stats.json
Please commit your changes or stash them before you merge.
Aborting
First, rewinding head to replay your work on top of it...
error: Your local changes to the following files would be overwritten by checkout:
	stats.json
Please commit your changes or stash them before you switch branches.
Aborting
fatal: Could not detach HEAD

  2、使用reset放弃本地修改,直接覆盖,然后再pull,正常

git reset --hard

三、解决方法

  尝试使用git stash save  --include-untracked stats.json 

  如果还不行,执行git reset --hard放弃本地修改


注意:本文归作者所有,未经作者允许,不得转载

全部评论: 0

    我有话说: