差点把整个博客弄没了

06 Jul 2020 Skill and Git

有惊无险。来记录一下查到的回滚git操作。

Step 1 - 通过 git reflog 查看历史变更记录

e.g.

d4356d9 (HEAD -> gh-pages, origin/gh-pages) HEAD@{0}: pull: Merge made by the 'recursive' strategy.
0adebda HEAD@{1}: checkout: moving from Minus to gh-pages
0a0e434 (Minus) HEAD@{2}: commit: Revert "Update: Fix Branch"
d86774a HEAD@{3}: checkout: moving from Minus to Minus
d86774a HEAD@{4}: commit: Update: Fix Branch
cd32070 HEAD@{5}: undo: updating HEAD
6de56c5 HEAD@{6}: commit: Update: Upload New Post
cd32070 HEAD@{7}: reset: moving to HEAD
cd32070 HEAD@{8}: commit (amend): Update Page Elem
62d2e0d (origin/Minus) HEAD@{9}: checkout: moving from 62d2e0d976f715e132b1c61e263a31ccd0e74d45 to Minus
62d2e0d (origin/Minus) HEAD@{10}: checkout: moving from gh-pages to 62d2e0d976f715e132b1c61e263a31ccd0e74d45
0adebda HEAD@{11}: merge origin/gh-pages: Merge made by the 'recursive' strategy.
62d2e0d (origin/Minus) HEAD@{12}: commit: Update Page Elem
585f934 HEAD@{13}: commit: Update: Index

Step 2 - 使用git reset --hard HEAD@{n},(n是你要回退到的引用位置)回滚操作

比如上文可运行 git reset --hard d86774a

Comments