别人在
git stash
后,又去修改了一些文件导致在
git pull
后的
git stash pop
出错:
Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ git stash pop error: Your local changes to the following files would be overwritten by merge: .idea/modules.xml gradle.properties Please, commit your changes or stash them before you can merge. Aborting Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) |
此处不敢擅自去
git stash
担心会把之前stash暂存的内容覆盖掉
而导致与之前修改的内容都丢失
去看了看
git status:
$ git status On branch master Your branch is up-to-date with ‘origin/master’. 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) modified: .idea/gradle.xml modified: .idea/modules.xml deleted: Jiandao.iml deleted: app/app.iml modified: gradle.properties Untracked files: (use “git add <file>…” to include in what will be committed) .gradle/ build/ no changes added to commit (use “git add” and/or “git commit -a”) Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ |
搜:
git stash pop error Your local changes to the following files would be overwritten by merge
How do I merge local modifications with a git stash without an extra commit? – Stack Overflow
How to force Git to overwrite local files on pull – Quora
error: Your local changes to the following files would be overwritten by merge – xlgps.com
git stash list
最后是:
使用:
git checkout — file_you_want_throw_away
去扔掉当前无用的两个修改了的文件
然后再去stash pop,即可:
Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ git status On branch master Your branch is up-to-date with ‘origin/master’. 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) modified: .idea/gradle.xml modified: .idea/modules.xml deleted: Jiandao.iml deleted: app/app.iml modified: gradle.properties Untracked files: (use “git add <file>…” to include in what will be committed) .gradle/ build/ no changes added to commit (use “git add” and/or “git commit -a”) Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ git stash list stash@{0}: WIP on master: 92e40c4 我的模块代码提交,新增FileUtil工具类,更新StringUtil,追加几个方法 stash@{1}: WIP on master: bbd126f 当前聊天页面,接收消息,插入到消息列表,滚动至底。 Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ git stash list stash@{0}: WIP on master: 92e40c4 我的模块代码提交,新增FileUtil工具类,更新StringUtil,追加几个方法 stash@{1}: WIP on master: bbd126f 当前聊天页面,接收消息,插入到消息列表,滚动至底。 Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ git stash Saved working directory and index state WIP on master: 714ac02 Merge remote-tracking branch ‘remotes/origin/master’ HEAD is now at 714ac02 Merge remote-tracking branch ‘remotes/origin/master’ Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ git stash list stash@{0}: WIP on master: 714ac02 Merge remote-tracking branch ‘remotes/origin/master’ stash@{1}: WIP on master: 92e40c4 我的模块代码提交,新增FileUtil工具类,更新StringUtil,追加几个方法 stash@{2}: WIP on master: bbd126f 当前聊天页面,接收消息,插入到消息列表,滚动至底。 Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ git pull Already up-to-date. Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ git stash pop Removing app/app.iml Removing Jiandao.iml On branch master Your branch is up-to-date with ‘origin/master’. 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) modified: .idea/gradle.xml modified: .idea/modules.xml deleted: Jiandao.iml deleted: app/app.iml modified: gradle.properties Untracked files: (use “git add <file>…” to include in what will be committed) .gradle/ build/ no changes added to commit (use “git add” and/or “git commit -a”) Dropped refs/stash@{0} (8073e00a2e7099a330d3a3288641fefb4fd63bd9) Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ git stash pop error: Your local changes to the following files would be overwritten by merge: .idea/modules.xml gradle.properties Please, commit your changes or stash them before you can merge. Aborting Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ git checkout — .idea/modules.xml Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ git checkout — gradle.properties Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ git status On branch master Your branch is up-to-date with ‘origin/master’. 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) modified: .idea/gradle.xml deleted: Jiandao.iml deleted: app/app.iml Untracked files: (use “git add <file>…” to include in what will be committed) .gradle/ build/ no changes added to commit (use “git add” and/or “git commit -a”) Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ git pull Already up-to-date. Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ git stash pop Auto-merging app/src/main/java/com/webbonn/jiandao/utils/JsonUtil.java On branch master Your branch is up-to-date with ‘origin/master’. Changes to be committed: (use “git reset HEAD <file>…” to unstage) new file: app/libs/gson-2.5.jar new file: app/src/main/java/com/webbonn/jiandao/interfere/HttpCallBack.java new file: app/src/main/java/com/webbonn/jiandao/ui/activity/UserChangePasswordActivity.java new file: app/src/main/java/com/webbonn/jiandao/utils/Map2Json.java new file: app/src/main/res/layout/activity_user_change_password.xml Changes not staged for commit: (use “git add <file>…” to update what will be committed) (use “git checkout — <file>…” to discard changes in working directory) modified: .idea/gradle.xml modified: .idea/modules.xml modified: Jiandao.iml modified: app/app.iml modified: app/build.gradle modified: app/src/main/AndroidManifest.xml modified: app/src/main/java/com/webbonn/jiandao/config/ServerConstant.java modified: app/src/main/java/com/webbonn/jiandao/ui/activity/UserInfoActivity.java modified: app/src/main/java/com/webbonn/jiandao/ui/activity/UserInfoEditActivity.java modified: app/src/main/java/com/webbonn/jiandao/ui/entity/UserEntity.java modified: app/src/main/java/com/webbonn/jiandao/utils/JsonUtil.java modified: app/src/main/java/com/webbonn/jiandao/utils/NetUtil.java modified: app/src/main/res/layout/activity_user_info.xml modified: app/src/main/res/values/strings.xml modified: gradle.properties Untracked files: (use “git add <file>…” to include in what will be committed) .gradle/ build/ Dropped refs/stash@{0} (a756d56d6e077518fac0d8995ab8fdeb80ed054c) Admin@Admin-ZY MINGW64 /d/android home/project/jiandao (master) $ |
抽空可以继续去试试:
git stash clear: 清空Git栈
转载请注明:在路上 » [已解决]git stash pop出错:error Your local changes to the following files would be overwritten by merge