# git 撤销
1. 未添加进暂存区的撤销 --未git add
2.添加进暂存区的撤销-- 已git add 未git commit
未添加进暂存区的撤销命令:git checkout -- filename 例如撤销test文件:git checkout -- test
如果是批量撤销使用命令:git checkout -- . (点代表撤销所有修改的文件)
添加进暂存区的撤销命令: git reset HEAD filename 例如撤销已commit的文件test git reset HEAD test
如果是批量撤销 使用命令 : git reset HEAD
已经提交了(git commit 已push )想要撤销某次提交: git revert commitId 例如撤销已push 的id 为4sd4de : git revert 4sd4de 如果git revert 同一个id,2次会还原成未git revert的内容(基数次的git revert会让内容失效,偶数次i会让内容生效) # git 回滚 git reset 回退到某次提交,该提交以后的提交都回退 git reset --hard commitId