我开了个藏宝箱,合并发生了冲突。与被列为重复的问题不同,我已经在我想保留的目录中有一些未提交的更改。我不只是想让合并冲突消失,还想让我的目录恢复到弹出窗口之前的状态。
我尝试了git合并-abort,但git声称没有合并正在进行中。是否有一种简单的方法来中止弹出,而不破坏我原来在目录中的更改?
我开了个藏宝箱,合并发生了冲突。与被列为重复的问题不同,我已经在我想保留的目录中有一些未提交的更改。我不只是想让合并冲突消失,还想让我的目录恢复到弹出窗口之前的状态。
我尝试了git合并-abort,但git声称没有合并正在进行中。是否有一种简单的方法来中止弹出,而不破坏我原来在目录中的更改?
当前回答
简单的一行
我总是用
Git重置—合并
我不记得它曾经失败过。
注意:git重置——合并将丢弃任何阶段性更改。此外,正如@Saroopashree Kumaraguru在评论中指出的那样,隐藏的内容不会丢失,以后可以重新应用。
其他回答
如果你不需要担心你所做的任何其他更改,你只想回到上次提交,那么你可以这样做:
git reset .
git checkout .
git clean -f
使用git reflog列出在git历史中所做的所有更改。复制一个动作id,输入git reset ACTION_ID
I'm posting here hoping that others my find my answer helpful. I had a similar problem when I tried to do a stash pop on a different branch than the one I had stashed from. On my case I had no files that were uncommitted or in the index but still got into the merge conflicts case (same case as @pid). As others pointed out previously, the failed git stash pop did indeed retain my stash, then A quick git reset HEAD plus going back to my original branch and doing the stash from there did resolve my problem.
合并——只有当你合并其他分支代码并且它有冲突时才会中止。
git merge --abort
如果stash pop有冲突,你可以使用:
git reset --merge
尝试使用if跟踪文件。
git rm <path to file>
git reset <path to file>
git checkout <path to file>