7

git回退已在本地提交未push的commit

 1 year ago
source link: https://www.wencst.com/archives/2258
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

git回退已在本地提交未push的commit

作者: wencst 分类: JAVA,程序设计 发布时间: 2022-06-09 17:13 阅读: 18 次
# git log
commit 6872405022f76eab1c0bec8ed97bef41a1621f03 (HEAD -> master, origin/master, origin/HEAD)
Merge: 26b3c49a 19bd58bc
Author: Kubernetes Prow Robot <[email protected]>
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 <[email protected]>
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~

如果文章对您有用,扫一下支付宝的红包,不胜感激!

欢迎加入QQ群进行技术交流:656897351(各种技术、招聘、兼职、培训欢迎加入)

Leave a Reply Cancel reply

You must be logged in to post a comment.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK