git rebase ate my commits ! Translate 'git reflog' output for me?

前提是你 提交于 2019-12-05 22:44:40

My preferred method is to stick a label on the thing you want to get back, like a branch:

git branch recover 705736f

At this point you can check it out (it's a new local branch) and make sure you've recovered what you wanted:

git checkout recover
git log    # or gitk, or whatever

This is a new branch label, pointing at the old (pre-rebase-attempt) commits.

Your new commit (Decorator demo added) will be on the other branch, which (in a graph log viewer, like gitk --branches or git log with --graph) forks off after the Early version of the decorators demo commit.


If you're willing to "lose" (except for in the reflog) the new commit, you can force-reset your current branch back to the old commit in the reflog:

git reset --hard 705736f

(instead of creating a new branch to point to 705736f). Again, run git log to see if that's where you want (you can even git log 705736f first!).

Just do:

$ git reset --hard HEAD@{3}

and you'll get back to the point where you did your last commit. From then you can act accordingly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!