git代碼 回滾

  1. 第一步:
    使用命令行 git log 獲取 push記錄
    對應的命令行:

    git log
    

    獲取到的數據:

    
    commit a49f0521de426e0f3375faead56b26b667ed90f7 (HEAD -> master, origin/master)
    Author:GerryRun <[email protected]>
    Date:   Wed Nov 6 14:26:05 2019 +0800
    
        <E6><96><B0><E5><A2><9E><E7><89><88><E6><9C><AC><E5><8F><B7><E5><88><B0>3
    
    commit da68fe032c563cbc4fd6a6189582d43110a8ee0d
    Author: GerryRun <[email protected]>
    Date:   Wed Nov 6 14:25:10 2019 +0800
    
        <E6><96><B0><E5><A2><9E><E7><89><88><E6><9C><AC><E5><8F><B7><E5><88><B0>2
    
    commit abd98559a0eca041f0feb8625751a0e38bd5304c
    Merge: 6a44116 d5619f9
    Author: GerryRun <[email protected]>
    Date:   Wed Nov 6 14:18:13 2019 +0800
    
        Merge branch 'master' of https://gitee.com/gerryrun/kotlinDemo
    
    commit 6a44116142cc99264fbb3e29c4c037ac7b59c254
    Author: GerryRun <[email protected]>
    Date:   Wed Nov 6 14:05:06 2019 +0800
    
        <E5><88><9D><E5><A7><8B><E5><8C><96><E9><A1><B9><E7>AE>
    
    commit d5619f959e1e0d77b49222054f45ae53d9d021bd
    Author: GerryRun <[email protected]>
    Date:   Wed Nov 6 11:59:22 2019 +0800
    
        Initial commit
    
    

    使用獲取到的 commit id進行回滾操作:

    **commit abd98559a0eca041f0feb8625751a0e38bd5304c**
    
  2. 第二步:
    使用命令行進行回滾操作

    git reset --hard abd98559a0eca041f0feb8625751a0e38bd5304c
    

    執行命令之後,回滾成功:
    日誌如下:

    E:\LearnDemo\MyApplication>git reset --hard da68fe032c563cbc4fd6a6189582d43110a8ee0d
    HEAD is now at da68fe0 新增版本號到2
    
    

至此,此教程完事兒~~

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章