合并冲突期间的`git stash` [英] `git stash` during a merge conflict

查看:466
本文介绍了合并冲突期间的`git stash`的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们做了一些坏事。



我们在合并冲突期间运行了 git stash save ,现在我们无法恢复我们的工作。



我们尝试过的事情:

  git pull -Xours origin master 
git stash apply --index

并且:

  git pull原点大师
git存储空间--keep-index合并冲突
git存储应用存储@ {1}

请帮助!

解决方案

这个问题似乎是: git stash 不保存对您要合并的分支的引用。在合并过程中,它被存储在名为 MERGE_HEAD 的ref中。为了修复它并返回到以前的版本状态,您需要找到您要合并的修订版本(让我们假装它是d7a9884a380f81b2fbf002442ee9c9eaf34ff68d),然后在应用存储器后将MERGE_HEAD设置为它。

然后,

然后您可以应用藏品(使用--index重新设置之前展示的所有内容),并设置您的 MERGE_HEAD

  git stash apply --index 
git update-ref MERGE_HEAD d7a9884a380f81b2fbf002442ee9c9eaf34ff68d


We've done something bad.

We ran git stash save during a merge conflict, and now we can't restore our work.

Things we've tried:

git pull -Xours origin master
git stash apply --index

And:

 git pull origin master
 git stash save --keep-index "merge conflicts"
 git stash apply stash@{1}

Please help!

解决方案

The issue seems to be that git stash doesn't save a reference to the branch you were trying to merge in. During a merge, this is stored in a ref named MERGE_HEAD.

To fix it and get back to your previous state, you need to find the revision (let's pretend it's d7a9884a380f81b2fbf002442ee9c9eaf34ff68d) you were trying to merge in, and set MERGE_HEAD to it after you apply the stash.

Then you can apply the stash (with --index to re-stage everything that was staged before), and set your MERGE_HEAD:

git stash apply --index
git update-ref MERGE_HEAD d7a9884a380f81b2fbf002442ee9c9eaf34ff68d

这篇关于合并冲突期间的`git stash`的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆