zoukankan      html  css  js  c++  java
  • git撤销commit

    撤销本地commit


    1. 找到上次git commit的 id

    在要撤销的文件夹下,执行git log,查看commit日志

    E:12.GITdocs数据库模型数据微服务sqls>git log
    commit 5947b953bbb1ef8ebed617b015fd4530cb7565ff
    Author: zhaop
    Date: Sat Dec 2 22:18:24 2017 +0800
    
    add index
    
    commit d5b5e420d7237c6dac724c8c0c459d53dcee775d
    Author: zhaop 
    Date: Sat Dec 2 17:56:39 2017 +0800
    
    user_statistics_day 增加total_user
    device_online_total online_total/login_ts改为bigint
    data_stats_result add
    
    commit f9651c7d79ea4701131f57b4d0320ebce96146f1
    Author: liu
    Date: Sat Dec 2 17:24:09 2017 +0800
    
    恢复版本
    
    commit 54537413e31d8bba90c1dcf5007d0f7dfba3a33e
    Author: 小王 <593817875@qq.com>

    找到你想撤销的commit_id

    2. git reset --hard commit_id

    E:12.GITdocs数据库模型数据微服务sqls>git reset --hard d5b5e420d7237c
    6dac724c8c0c459d53dcee775d

    完成撤销,同时将代码恢复到前一commit_id 对应的版本。git push新代码,然后再commit

    3. git reset commit_id
    完成Commit命令的撤销,但是不对代码修改进行撤销,可以直接通过git commit 重新提交对本地代码的修改。

    撤销远程commit


    你已经执行了 git push, 把你的修改发送到了 GitHub,现在你意识到这些 commit 的其中一个是有问题的,你需要撤销那一个 commit.

    ```
    git revert <SHA>
    ```


    更详细使用请参考
    http://blog.jobbole.com/87700/

  • 相关阅读:
    axios,ajax,xhr 请求携带Cookie
    js中reduce的方法和去重
    H5图片预览
    网页唤起qq加群
    tab切换中嵌套swiper轮播
    CantOS的安装
    共享文件夹或文件
    Vue中,iframe中的子网页,调用父网页的方法
    禁止未使用的变量 ( `no-unused-vars`)
    vite + vue3 + ts搭建项目
  • 原文地址:https://www.cnblogs.com/iiot/p/7978840.html
Copyright © 2011-2022 走看看