1.放弃本地更改,未add,未commit
git checkout filename
2.放弃已add未commit更改
git reset HEAD filename //撤销add操作,本地修改不会丢失
3.放弃commit的更改
git reset --hard HEAD^ //回到上个版本 git reset --hard HEAD^^ //回到上上个版本 git reset --hard commitID //回到指定版本
4.放弃已push更改
git reset HEAD //移动HEAD指针 git revert commitID //将指定版本作为新版本提交
文章评论