如何删除不需要的git提交? [英] How to remove unneeded git commits?

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

问题描述

我在我的git存储中有一些垃圾提交。这些是由例如git gui在再次更改最新提交时意外创建更多提交。

现在我有了一些提交,并且没有分配HEAD(分离,不是任何分支的一部分) 。

我想整理一下,我的问题是:如何删除这些提交(请参阅F,G和H)?这是使用rebase或回复或重置?或者使用其他工具?

  A  -  B  -  C  -  D  -  E [ master] 
\ - F - G
\ - H

感谢



基督徒

解决方案

试试这个:

  git reflog expire --expire = now 
git gc --prune = now


I have some garbage commits in my git repositry. These have been created by e.g. the git gui when changing the latest commit again and accidently creating additional commits.

Now I have some commits lying around with no HEAD assigned (detached, not part of any branch).

As I want to tidy up, my question is: How can I delete these commits (see F, G and H)? Is this done using rebase or revert or reset? Or using another tool? On which commit do I have to sit to do it?

A -- B -- C -- D -- E [master]
      \-- F -- G
           \-- H

Thanks

Christian

解决方案

Try this:

git reflog expire --expire=now
git gc --prune=now

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

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