git pull冲突 overwritten aborting
来源:互联网 发布:算法 c语言实现 pdf 编辑:程序博客网 时间:2024/06/04 18:33
From github.com:26huitailang/learn-sth-everyday 7cf57b0..d9f7ae2 master -> origin/masterUpdating 7cf57b0..d9f7ae2error: Your local changes to the following files would be overwritten by merge: liaoxuefeng/awesome-python-webapp/LICENSEPlease, commit your changes or stash them before you can merge.Aborting
起因:在家里台式更新了文件并同步到远程,而另外一台电脑在本地修改了文件没有提交到库中。
解决办法:
处理的方式非常简单,主要是使用git stash命令进行处理,分成以下几个步骤进行处理。
1. git stash将本地修改存储起来
$ git stash
保存当前的工作进度,会分别对暂存区和工作区的状态进行保存 。用git stash list可以显示进度列表,也暗示了git stash可以多次保存工作进度,并在恢复的时候进行选择。
其中stash@{}这样标记的就是刚才保存的信息。WIP表示work in progress,就是工作区的意思。
2. git pull远程到本地
保存了本地进度之后,就可以pull了,git pull相当于git fetch和git merge两个操作。
$ git pull
可以看到我的本地信息被远程的覆盖掉了。remote file changed是我在github上直接提交的commit。覆盖了我本地的另外一句话。
不用担心,因为我们保存了本地的工作进度,可以从stash list中恢复之前的信息。
3. 还原暂存区的内容
$ git stash pop stash@{1}or$ git stash apply stash@{1}
此时,遇到了另外一个问题,提示:
fatal: ambiguous argument 'stash@': unknown revision or path not in the working tree.
因为我使用的是powershell上操作,在SO上找到的答案:
Your shell is eating your curly brackets, so while you say stash@{1}, git sees stash@1 and that makes no sense to it. Quote the argument or reconfigure your shell to only expand curly brackets when there is a comma between them (zsh can be configured either way, bash only expands curly brackets with comma or range between them, other shells may behave one or other way).
简而言之,windows上为了escape {}被吃掉,加上backtick `就好。
$ git stash apply stash@`{1`}
系统提示如下类似的信息:
PS D:\learn-sth-everyday\practice\spider> git stash apply stash@`{1`}Auto-merging .idea/workspace.xmlCONFLICT (content): Merge conflict in .idea/workspace.xml
意思就是系统自动合并修改的内容,但是其中有冲突,需要解决其中的冲突。
4. 解决文件中冲突的的部分
直接打开文件冲突的文件。
其中Updated upstream 和=====之间的内容就是pull下来的内容,====和stashed changes之间的内容就是本地修改的内容。碰到这种情况,git也不知道哪行内容是需要的,所以要自行确定需要的内容。完成后再执行提交操作。
会用mergetool的也可以用这个工具去做。
5. 最后记得git stash clear删除进度列表,不然用的多了会stash list会变得很复杂。
参考:
- git权威指南,里面有git stash专门的一章讲解
- Stack Overflow,powershell的escape问题
- git pull冲突 overwritten aborting
- Git pull 冲突解决
- Git pull 冲突解决方案
- git pull 冲突解决
- 处理git pull 冲突
- git pull冲突
- git pull冲突
- git pull 出现冲突
- git pull :因为文件冲突pull失败
- git pull 代码冲突解决方法
- git pull和本地文件冲突
- Git pull error:Your local changes to the following files would be overwritten by merge解决方法
- Git pull error: Your local changes to the following files would be overwritten by merge:
- git pull error: your local changes to the following files would be overwritten......
- 解决GIT PULL冲突: 终极方法
- 使用git pull命令时冲突
- git pull 和本地文件冲突问题解决
- git pull 和本地文件冲突问题解决
- VirtualBox NAT方式设置CentOs7的IP为10.0.2.2时SSH登录拒绝
- 顶级pom和子pom版本批量修改
- 一些记不住的css
- 获取ApplicationContext
- 虚拟机性能监控与故障处理工具(四)
- git pull冲突 overwritten aborting
- wifi工具类
- 如何设置td中溢出内容的隐藏显示
- 欢迎使用CSDN-markdown编辑器
- Spring Boot中使用Spring Security进行安全控制
- 语音的线性预测系数(Linear Prediction Coefficient,LPC)
- 利用AndroidStudio模拟器运行项目时 报出异常
- Camera’s Depth Texture
- 【Unity3D入门教程】Unity3D简介、安装和程序发布