1.cd 切换至 代码目录 ,右键–》git bash here
2.git log 查看提交 记录获取 commitId
3.git reset commitId 重置指定提交记录 id
4.git stash 暂存修改 (非必须)
5.git push --force 强制push
如果出现 remote: GitLab: You are not allowed to force push code to a protected branch on this project.则需要修改
如图:
最后点击 Unprotect即可。再次执行步骤5 ,成功。指定提交记录被删除。
注:删除某次提交记录后,记得恢复 Unprotect。
6.git stash pop 释放暂存的修改,开始修改代码 (非必须)
7.git add . -> git commit -m “massage” -> git push (非必须)