Git 本地代码处于 detached HEAD(游离状态)的解决步骤

【报错描述】Git 本地代码提交时,提示处于 detached HEAD(游离状态),图示如下:

【解决步骤】
下面的解决步骤要顺序执行:

  1. git commit 进行提交(提交完本地分支指向的是刚 commit 完的状态码,类似上图中的:f95490b9);
  2. git branch short f95490b9 这句执行是在本地创建一个short分支,并将刚才 commit 的内容放到新分支里面存储;
  3. git checkout short 切换到刚才新建的分支(如果已经处于 short 分支,可以忽略这一步);
  4. git checkout master 切换到原来开发的分支(master只是一个分支,可以切换到任意分支 );
  5. git merge short 将之前存储到 short 分支上的内容合并到当前的分支上;
  6. git branch -d short 删除 short 临时分支(可以不删除)。有的电脑上 -d 参数不生效,需要 -D 才生效;
  7. 再次将代码commit and push一次;
  8. 完成以上步骤,游离状态解除,本地代码已经合并到远程master分支上了。

【效果演示】

Microsoft Windows [版本 10.0.18362.387]
(c) 2019 Microsoft Corporation。保留所有权利。

E:\WebstormProjects\wyrjhj-project>git branch short f95490b9

E:\WebstormProjects\wyrjhj-project>git checkout short
Switched to branch 'short'

E:\WebstormProjects\wyrjhj-project>git checkout master
Switched to a new branch 'master'
Branch 'master' set up to track remote branch 'master' from 'origin'.

E:\WebstormProjects\wyrjhj-project>git merge short
Updating e5fd27c..f95490b
Fast-forward
 src/common/service/config.service.js         |   4 +-
 src/pages.json                               |  52 +++-
 src/pages/wyrenju/home/home.vue              |   6 +-
 src/pages/wyrenju/notice/notice.vue          |  99 +++++---
 src/pages/wyrenju/pot/pot.vue                | 365 ---------------------------
 src/pages/wyrenju/warnInfo/warnInfo.vue      | 324 +++++++++++++-----------
 src/pages/wyrenju/wastes/chemical.vue        | 207 +++++++++++++++
 src/pages/wyrenju/wastes/chemicalAdd.vue     | 152 +++++++++++
 src/pages/wyrenju/wastes/chemicalEdit.vue    | 130 ++++++++++
 src/pages/wyrenju/wastes/distributor.vue     | 151 +++++++++++
 src/pages/wyrenju/wastes/distributorAdd.vue  |  94 +++++++
 src/pages/wyrenju/wastes/distributorEdit.vue | 108 ++++++++
 src/pages/wyrenju/wastes/pot.vue             | 199 +++++++++++++++
 src/pages/wyrenju/wastes/potAdd.vue          |  95 +++++++
 src/pages/wyrenju/wastes/potEdit.vue         |  80 ++++++
 src/pages/wyrenju/wastes/wastes.vue          |  54 ++++
 16 files changed, 1567 insertions(+), 553 deletions(-)
 delete mode 100644 src/pages/wyrenju/pot/pot.vue
 create mode 100644 src/pages/wyrenju/wastes/chemical.vue
 create mode 100644 src/pages/wyrenju/wastes/chemicalAdd.vue
 create mode 100644 src/pages/wyrenju/wastes/chemicalEdit.vue
 create mode 100644 src/pages/wyrenju/wastes/distributor.vue
 create mode 100644 src/pages/wyrenju/wastes/distributorAdd.vue
 create mode 100644 src/pages/wyrenju/wastes/distributorEdit.vue
 create mode 100644 src/pages/wyrenju/wastes/pot.vue
 create mode 100644 src/pages/wyrenju/wastes/potAdd.vue
 create mode 100644 src/pages/wyrenju/wastes/potEdit.vue
 create mode 100644 src/pages/wyrenju/wastes/wastes.vue

E:\WebstormProjects\wyrjhj-project>
已标记关键词 清除标记
©️2020 CSDN 皮肤主题: 技术工厂 设计师:CSDN官方博客 返回首页