如何删除错误的合并提交? [英] How to delete erroneous merge commits?

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

问题描述

通过喜剧的noob错误,我发现自己在本地repo中出现以下情况:



使用 git reset 我操纵了分支标签到我想要的地方,现在我想删除看起来像未命名分支的3个提交。我已经研究/尝试了各种各样的东西,包括 gc prune ,但没有成功。



我知道我可以放弃当地的回购并重新克隆它,但是我想用它作为学习机会。



<所以问题是:我该如何删除那些提交?

你看过 reflog ?它跟踪HEAD在仓库中移动的各种方式(并通过阻止自动删除提交来完成工作)。



用<$ c $来检查它c> git reflog 或 git log -g 。使用> git reflog expire --expire = now --all 来破解它,然后您可以垃圾收集未使用的提交。


Through a comedy of noob errors I find myself in the following situation in a local repo:

Using git reset I have maneuvered the branch tags to where I want them, and I would now like to delete the 3 commits on what looks like an unnamed branch. I have researched/tried a variety of things including gc, prune without success.

I realize that I could just blow away the local repo and re-clone it, however I'd like to use it as a learning opportunity.

So the question is: How can I delete those commits?

解决方案

Have you looked at the reflog? It keeps track of every way that HEAD moves inside your repository (and it’s doing its job by preventing the automatic deletion of your commits).

Examine it with git reflog or git log -g. Nuke it with git reflog expire --expire=now --all, and then you can garbage collect the unused commits.

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

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