• git push之后想撤销这次的修改该怎么做?


    git push过后撤销修改

    1. 使用git reset --hard 要回滚的版本号 ,再 git reset 最新的版本号
      操作:首先对测试.txt文件进行三次修改

      文件里面有内容1 2 3,现在使用git reset --hard 回滚到1上面,git提示HEAD is now at 2a1d20f 1 也就是head位于1上面
      然后git push的时候会提示:
    error: failed to push some refs to 'https://github.com/466879168/Article.git'
    hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. Integrate the remote changes (e.g.
    hint: 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    

    然后git reset 最新版本号 然后add commit -m push之后就OK了
    2. 使用git reset –soft
    3. 使用git reset –mixed

    三者区别:

    • git reset –soft 不会改变stage(暂存区)区,仅仅将commit回退到了指定的提交
    • git reset –mixed 不会改变工作区,但是会用指定的commit覆盖stage区也就是清空暂存区
    • git reset –hard 使用指定的commit的内容覆盖stage区和工作区
  • 相关阅读:
    树的直径 学习笔记
    SDOJ 3742 黑白图
    【SDOJ 3741】 【poj2528】 Mayor's posters
    SDOJ 3740 Graph
    SDOJ 3696 Tree
    SDOJ 1195 Zhenhuan
    又一次受刺激后的发奋
    html_表单form中的input类型大集合
    js_表格的增删改
    JS_拖拽窗口的实现
  • 原文地址:https://www.cnblogs.com/my466879168/p/12960690.html
Copyright © 2020-2023  润新知