IDEA : Git Pull Failed 解决(IDEA中使用stash功能)

一、问题:

本地要commit代码,commit之前需pull代码,但pull提示冲突。如下

Git Pull Failed Your local changes would be overwritten by merge. Commit, stash or revert them to proceed.

二、分析:

原因很简单,代码冲突。解决也很简单,如图提示那样。Commit, stash or revert 。

revert 就算了,Commit需要先Pull,肯定失败,只剩下stash。但是怎么stash呢?

三、Git 操作步骤:

1. 本地代码先 git stash ;(stash作用见参考)

2. 然后pull代码;

3. 最终再讲本地代码 git stash pop;

四、IDEA中实际操作:

1、stash:

2、unstash:

五、参考:

  1. How do I resolve git saying "Commit your changes or stash them before you can merge"? - Stack Overflow https://stackoverflow.com/questions/15745045/how-do-i-resolve-git-saying-commit-your-changes-or-stash-them-before-you-can-me (很详细了,几乎说了所有冲突的解决方法)
  2. Git冲突:commit your changes or stash them before you can merge. - CSDN博客 http://blog.csdn.net/lincyang/article/details/21519333 (解释的也很详细,这个说的是Git命令,自行尝试在IDEA中应用)
  3. Git Stash用法 - 简书 https://www.jianshu.com/p/ea88b6a22fcb (详细讲解了Git Stash以及相关命令的用法)
posted @ 2018-02-12 14:20  不无聊  阅读(5512)  评论(0编辑  收藏  举报