git回退已在本地提交未push的commit
方式一
# git log
commit 6872405022f76eab1c0bec8ed97bef41a1621f03 (HEAD -> master, origin/master, origin/HEAD)
Merge: 26b3c49a 19bd58bc
Author: Kubernetes Prow Robot <k8s-ci-robot@users.noreply.github.com>
Date: Tue Apr 26 09:20:52 2022 -0700
Merge pull request #2230 from kubernetes-client/dependabot/github_actions/github/codeql-action-2
Bump github/codeql-action from 1 to 2
commit 26b3c49a1f94d766dd8dd161abd390cf565699f8
Merge: b24f0460 da42b8cc
Author: Kubernetes Prow Robot <k8s-ci-robot@users.noreply.github.com>
Date: Tue Apr 26 09:18:52 2022 -0700
Merge pull request #2228 from kubernetes-client/dependabot/maven/org.sonatype.plugins-nexus-staging-maven-plugin-1.6.13
Bump nexus-staging-maven-plugin from 1.6.12 to 1.6.13
# git reset 26b3c49a1f94d766dd8dd161abd390cf565699f8q
其中26b3c49a1f94d766dd8dd161abd390cf565699f8为git log 所查询出的要回退到版本的commitID
方式二
回退到上次提交,并删除已提交代码
git reset --hard HEAD^
方式三
回退到上次提交,并保留已提交代码
git reset --soft HEAD~1
方式四(推荐)
回退上次提交,并将代码回到本地的local changes 列表中
git reset HEAD~