2015-06-15 68 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 
相關問題