git 合并head 到master

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

出现head 的项目中:
查看分支状态, 检出master分支

➜  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 <new-branch-name> 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

创建tmp暂存分支, 合并tmp到master

➜  CloudSchoolSubmodule git:(master) git branch tmp 8830b0f
➜  CloudSchoolSubmodule git:(master) git branch
* master
  tmp
➜  CloudSchoolSubmodule git:(master) git merge tmp

最后再删除临时分支tm ,至此搞定~

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值