git add与commit撤销

1、git add撤销

工作中常会遇见提交代码的时候不小心写成了git add .,本想提交个别文件,结果把所有文件都提交了,这是就需要用到撤销操作

git reset HEAD (撤销全部的add)

git reset HEAD xx.js(撤销某个文件的提交)

2、git commit撤销

首先使用git log 查看上一次的提交commitId

git reset --soft commitId (保存代码,仅撤销commit操作,git status无法查看文件改变状态)

git reset --mixedcommitId (保存代码,撤销add、commit操作,git status可以查看文件状态--红色)

猜你喜欢

转载自blog.csdn.net/qq_39480597/article/details/82627215