2015-06-15 66 views
4

我有两个分支master和development。我藏在主人身上,例如现在Git stash在master分支上弹出

git stash 
git checkout development 

,我是在发展分支,但错误我打开藏匿

git stash pop 

而现在它显示了冲突。我使用此重置git:

git reset HEAD 

但它仍然显示冲突。我也需要我的存储在主分支。我该如何解决这个问题?

+2

的可能重复[撤消意外git的藏匿处弹出](http://stackoverflow.com/questions/6543519/undoing-accidental-git-stash-pop) –

回答

2

git reset HEAD不会触摸工作树,只是索引。实际上,它只会暂停staged文件,因为HEAD是您的当前分支已经在哪里(这是HEAD的定义)。

git reset --hard HEAD将修复工作树以反映HEAD

如果git pop不适用干净,应该保留藏匿。

从人混帐藏匿处:

运用状态可能会失败,冲突;在这种情况下,它不会从存储列表中删除。您需要手动解决冲突,然后手动调用git stash drop。

所以只是做:

git checkout master 
git stash pop 
#or `git stash apply` if you don't want to drop the stash even if it does apply cleanly 
+0

有没有什么办法让失去的藏匿 – Rohit

+0

如果你有冲突,应该保留隐藏,即不应该丢失。 – PSkocik

+0

如果消失了,您应该可以在[reflog](https://git-scm.com/docs/git-reflog)中找到它。 –

1

尝试使用看在git的藏匿手动

git stash --help 

它在情况下,你清楚/降藏匿怎么办节意外地。这将有助于理解在这种情况下将要完成的工作。

Recovering stashes that were cleared/dropped erroneously 
    If you mistakenly drop or clear stashes, they cannot be recovered through the normal safety mechanisms. However, you can try the 
    following incantation to get a list of stashes that are still in your repository, but not reachable any more: 

     git fsck --unreachable | 
     grep commit | cut -d\ -f3 | 
     xargs git log --merges --no-walk --grep=WIP 
相关问题