我如何删除unpushed git提交? [英] How do I delete unpushed git commits?

查看:196
本文介绍了我如何删除unpushed git提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我意外地犯了错误的分支。
如何删除该提交?

解决方案

删除最近的提交,保留所做的工作:

  git reset --soft HEAD〜1 

删除最近的提交,销毁您完成的工作

  git reset --hard HEAD〜1 


I accidentally committed to the wrong branch. How do I delete that commit?

解决方案

Delete the most recent commit, keeping the work you've done:

git reset --soft HEAD~1

Delete the most recent commit, destroying the work you've done:

git reset --hard HEAD~1

这篇关于我如何删除unpushed git提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆