git 撤销更改的文件

在没有git add之前:

1.撤销所有更改:git checkout .

2.撤销指定文件的更改:git checkout -- file.txt

git add之后:

git reset HEAD file.txt

git push 之后:

git reset --hard  comittHash // git log --online可以查看hashid 返回到某个节点,不保留修改

git reset --soft  comittHash // git log --online可以查看hashid 返回到某个节点,保留修改

git reflog 查看全部提交的记录,回滚来,还可以回滚去,反复回滚,无所谓

 

 

原文地址:https://www.cnblogs.com/qiyc/p/9881181.html