Git HEAD 分支游离,切回 master 导致代码丢失的处理
从 master 分支切换到 branch 分支,无法切换。
git checkout develop
error: pathspec ‘develop’ did not match any file(s) known to git
此时查看 git 分支: git fetch
git branch -a
git reflog 查看提交记录
Git HEAD 分支游离
找到一个相对较新的未合并的分支 9a74436
git checkout 9a74436
$ git checkout 9a74436
Note: checking out '9a74436'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
HEAD is now at 9a74436 调整单元格颜色