git 合并head 到master


项目中经常会无缘无故的出现head ,每次合并到master都感觉很复杂。最近找到了一种相对简单的一种方法。

出现head 的项目中:

➜  CloudSchoolSubmodule git:(8830b0f) git branch
* (HEAD detached from a136430)
  master
➜  CloudSchoolSubmodule git:(8830b0f) git checkout master
Warning: you are leaving 2 commits behind, not connected to
any of your branches:

  8830b0f Merge branch 'master' of /CloudSchoolSubmodule into HEAD
  bb7cffe 日历修改提前20min 提醒

If you want to keep them by creating a new branch, this may be a good time
to do so with:

 git branch  8830b0f

Switched to branch 'master'
Your branch is behind 'origin/master' by 2 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
➜  CloudSchoolSubmodule git:(master) git branch
* master
➜  CloudSchoolSubmodule git:(master) git branch tmp 8830b0f
➜  CloudSchoolSubmodule git:(master) git branch
* master
  tmp
➜  CloudSchoolSubmodule git:(master) git merge tmp
最后再删除临时分支tm ,至此搞定~

你可能感兴趣的:(git)