首页 > 其他 > 详细

Git 中的“撤销”

时间:2020-03-20 21:21:22      阅读:39      评论:0      收藏:0      [点我收藏+]

(1)当commit 完后,发现少add几个文件,可以:

$ git commit -m ‘initial commit‘

$ git add forgotten_file

$ git commit --amend

(2) 修改了a.txt,但没有add 到暂存区,撤销到没有修改过该文件:

$ git restore a.txt

技术分享图片

(3)修改了a.txt,add到了暂存区,没提交,撤销到没添加到暂存区:

$ git restore --staged a.txt

技术分享图片

(4)回到某特定版本

$ git reset --hard ^HEAD

Git 中的“撤销”

原文:https://www.cnblogs.com/johnyang/p/12534613.html

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