GIT:如何挤压已被推送到远程回购的多个提交? [英] GIT: how to squash several commits that have been pushed to a remote repo?

查看:100
本文介绍了GIT:如何挤压已被推送到远程回购的多个提交?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的设置与Git。基本上我有:

I have a weird setup with Git. Basically I have:

[client 1] <---> [remote repo] ----> [client 2]



<客户端1>基本上是我正在使用的本地回购,因为我可以在本地机器上编译/构建项目。

[Client 1] is essentially the local repo I am working with, because I can't compile/build the project on my local machine.

[Client 2]是用于构建的远程服务器。

[Client 2] is a remote server for building.

在中间,我有另一个回购,[远程回购],基本上用于与我公司的CVS中央回购同步,并同步我的[客户1]和[客户2]。

In the middle, I have another repo, [remote repo], basically for synchronizing with a cvs central repo in my company, and also synchronizing between my [client 1] and [client 2].

由于所有的编译/构建工作都是在[客户端2]上完成的,因此我在[客户端1]上进行了许多简单的提交,只是为了修复编译或构建错误。

Since all the compiling/building is done on [client 2], I have many trivial commits on [client 1] just for fixing the compilation or building errors.

因此,当我发现上次提交时出现错误时,已经太晚了,因为提交已经被推送到远程仓库并从仓库中取出。

So by the time I find out there are errors in the last commit, it's already too late because the commit has already been pushed to and pulled from the remote repo.

如何将这些(许多)微不足道的提交压缩成一个?
Thanks。

How can I squash these (many) trivial commits into one? Thanks.

推荐答案

首先,避免挤压和一般重写历史,除非您绝对必须。 微不足道的提交并不是压制提交提交的理由。如果他们能留下来,让他们留下来。重写历史在CVS中并不简单,因为这些提交可能会进入CVS仓库,所以您应该可以忍受它。

First of all, avoid squashing and in general rewriting history unless you absolutely have to. Having "trivial" commits is not reason to squash pushed commits. If they can stay, let them stay. And rewriting history is not straightforward in cvs at all, so since these commits would have made their way into the cvs repo, you should probably live with it.

对于git远程回购,如果你想继续 - 我假设你知道你的本地回购( git rebase -i 很简单)压缩提交。压扁后,用 -f - 强制推送。

For the git remote repo, if you do wish to proceed - I assume you know to squash the commits on your local repo ( git rebase -i is straightforward). After the squash, push with a -f - a force push.

这篇关于GIT:如何挤压已被推送到远程回购的多个提交?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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