解決方案:
https://blog.csdn.net/hupoling/article/details/79017382
主要步驟:
git reflog
然后找到之前commit的分支
git checkout 1234412(那個序號) 切換過來
git checkout -b xxxxxxx (自己起名字)
git checkout master 切換過來
git merge xxxxxxx 合並上去
git branch -d xxxxxxx 刪掉臨時分支
演示如下: