zoukankan      html  css  js  c++  java
  • git删除本地和远程分支恢复办法

    需求
    实际工作上,肯定会有不小心的时候,删除了本地dev分支,也不小心删除了远程分支

    git reflog 


    reflog是reference log的意思,也就是引用log,记录HEAD在各个分支上的移动轨迹。选项 --date=iso,表示以标准时间格式展示。这里你肯定会问,为什么不用git log?git log是用来记录当前分支的commit log,分支都删除了,找不到commit log了。
    找到目标分支最后一次的commitid,

    1.  
      D:>git reflog --date=iso
    2.  
      287ba1b HEAD@{2019-05-13 15:35:18 +0800}: checkout: moving from dev to deploy
    3.  
      528a169 HEAD@{2019-05-13 09:23:58 +0800}: commit: 添加忽略,.idea,*.iml,*.log
    4.  
       


    切出分支

    git checkout -b recovery_branch_name commitid


    切出分支后,本地有分支了,再push到远程仓库就可以了

    git push  origin recovery_branch_name 


    恢复分支后,个人感受,git还是很强大的!

    每天进步一点点,成功就会在眼前!
  • 相关阅读:
    公有云数据库服务的申请与使用
    linux集群
    shell基础知识
    LNMP环境配置
    LAMP环境搭建与配置
    12月17日linux学习
    12月16日linux学习(文档的压缩与打包)
    12月13、14号linux学习
    12月12日linux学习
    目录结构
  • 原文地址:https://www.cnblogs.com/jmwan/p/14597723.html
Copyright © 2011-2022 走看看