Git删除推送提交 [英] Git delete pushed commits

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

问题描述

我在我的项目中使用git存储库。我不小心推了2个我不应该有的提交。在一个人之间已经承诺了。是否有可能删除我推送的提交,或者我必须删除我的代码更改并将其作为新提交推送,因为有人已经提交了它。



Git Master分支:



提交A // by me



提交B //由我



提交C // by some one



现在我必须删除提交A和B离开提交C.
任何帮助将非常感激。

解决方案

必须恢复这些提交。



技术上它所做的是删除这些更改并进行新的提交,并将其撤销。

现在,将它们还原将把他们留在历史上,但通常这是可以的。如果这完全不可接受,那么只需看看像过滤器分支和强制推送这样的解决方案。


I am using git repository in my project. I have accidentally pushed 2 commits which I shouldn't have. And in between some one has committed on top of it. Is it possible to remove my pushed commits or I have to remove my code changes and push it as new commit, since some one has committed on top of it.

Git Master branch :

Commit A // by me

Commit B // by me

Commit C // by some one

Now I have to delete Commit A and B leaving Commit C. Any help will be really appreciated.

解决方案

You'll have to revert those commits.

Technically what it does is that it removes those changes and makes a new commit, undoing them.

Now, reverting them will leave them on the history stil, but usually that is ok. If that's totally unacceptable only then look at the solutions like filter-branch and force pushes.

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

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