首页 > 其他 > 详细

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

时间:2020-05-25 20:55:05      阅读:85      评论:0      收藏:0      [点我收藏+]

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区和工作区

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

原文:https://www.cnblogs.com/my466879168/p/12960690.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!