在Git中重置后恢复磁头
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在Git中重置后恢复磁头相关的知识,希望对你有一定的参考价值。
This snippet shows how to restore HEAD after using Git's reset method (see http://gitready.com/2009/01/17/restoring-lost-commits.html?disqus_reply=5271828#comment-5271828).
# reseting $ git show-ref -h HEAD 7c61179cbe51c050c5520b4399f7b14eec943754 HEAD $ git reset --hard HEAD^ HEAD is now at 39ba87b Fixing about and submit pages so they don't look stupid $ git show-ref -h HEAD 39ba87bf28b5bb223feffafb59638f6f46908cac HEAD # the commit object still exists $ git fsck --lost-found [... some blobs omitted ...] dangling commit 7c61179cbe51c050c5520b4399f7b14eec943754 # showing the log of the old references of HEAD $ git reflog 39ba87b... [email protected]{0}: HEAD~1: updating HEAD 7c61179... [email protected]{1}: pull origin master: Fast forward [... lots of other refs ...] # restoring HEAD back from the dangling ref object hash $ git merge 7c61179 Updating 39ba87b..7c61179 Fast forward css/screen.css | 4 ++++ submit.html | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-)
以上是关于在Git中重置后恢复磁头的主要内容,如果未能解决你的问题,请参考以下文章