Git在reset -hard之后得到最新的提交

时间:2012-08-29 01:15:55

标签: git-reset

之前我做了一个git reset -hard FETCH_HEAD,我无法想出回到我最近的提交。

HEAD@{0}: checkout: moving from master to adding_events
HEAD@{1}: checkout: moving from adding_events to master
HEAD@{2}: checkout: moving from master to adding_events
HEAD@{3}: checkout: moving from 3458u9qfhaushf
HEAD@{4}: commit: Testing Gemfile edit
HEAD@{5}: checkout: moving from master to fajesnfkj24b
HEAD@{6}: commit: Changed Gemfile after reset
HEAD@{7}: reset: moving to FETCH_HEAD
HEAD@{8}: commit: Added Event Show page, Upload Event Pic
HEAD@{9}: commit: Add Category Database and Event pages
HEAD@{10}: merge adding_events: Fast-forward
HEAD@{11}: checkout: moving from adding_events to master
HEAD@{12}: commit: Replaced Post with Events

当我在我的主分支上执行git状态时,这就是出现的内容

Your branch and 'origin/master' have diverged,
and have 1 and 5 different commits each, respectively.

当我在我的目录中打开应用程序时,12提交“用事件替换帖子”是显示的最新文件。我想回到我上次提交的8“添加活动显示页面,上传活动图片”......任何想法?

1 个答案:

答案 0 :(得分:2)

你可以这样做:

git reset --hard HEAD@{8}

将当前分支指针重置为该特定提交。