2025年12月

问题来源

由于子模块的修改之前是直接拉取,并且没有指定分支,所以对于子模块的修改就提交到了一个匿名分支上。这个时候一个不小心切回主分支,之前的修改和提交就丢失了。

问题处理

把问题抛给AI后得到了 比较有效的一个线索是 reflog

解决方案如下:

关键流程 reflog -> git show xxx -> git cherry-pick xxx(earlier) -> git cherry-pick(later)

git reflog

b103067 HEAD@{4}: checkout: moving from b1fd2fc905252ce8e778d43c2cce00e69f8f1a3a to main
b1fd2fc HEAD@{5}: commit: add gui monitor for core loop
60bc476 HEAD@{6}: commit: add timezone offset
b103067 HEAD@{7}: checkout: moving from main to b103067914a6a61c2864c08892eb06289e76bffc

git show 60bc476
...

git checrry-pick 60bc476

git show b1fd2fc
git cherry-pick b1fd2fc