• 如何撤消当前提交


    Careful: git reset --hard WILL DELETE YOUR WORKING DIRECTORY CHANGES. Be sure tostash any local changes you want to keep before running this command.

    Assuming you are sitting on that commit, then this command will wack it...

    git reset --hard HEAD~1
    

    The HEAD~1 means the commit before head.

    Or, you could look at the output of git log, find the commit id of the commit you want to back up to, and then do this:

    git reset --hard <sha1-commit-id>
    

    If you already pushed it, you will need to do a force push to get rid of it...

    git push origin HEAD --force
    

    However, if others may have pulled it, then you would be better off starting a new branch. Because when they pull, it will just merge it into their work, and you will get it pushed back up again.

    If you already pushed, it may be better to use git revert, to create a "mirror image" commit that will undo the changes. However, both commits will be in the log.


    FYI -- git reset --hard HEAD is great if you want to get rid of WORK IN PROGRESS. It will reset you back to the most recent commit, and erase all the changes in your working tree and index.


    Lastly, if you need to find a commit that you "deleted", it is typically present in git reflog unless you have garbage collected your repository.

    http://stackoverflow.com/questions/1338728/delete-commits-from-a-branch-in-git

  • 相关阅读:
    zookeeper安装教程(zookeeper3.4.5为例)
    解决VMware虚拟机网络时长中断的问题
    Linux 服务器上快速配置阿里巴巴 OPSX NTP服务
    配置使用 NTP
    jenkins配置从节点
    微信裂变红包
    微信从业人员推荐阅读的100本经典图书
    微信红包限额提升方法
    微信朋友圈运营规则
    微信公众平台开发问答
  • 原文地址:https://www.cnblogs.com/softidea/p/5488360.html
Copyright © 2020-2023  润新知