且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

GIT:如何挤压已被推送到远程回购的多个提交?

更新时间:2021-12-04 05:25:24

首先,避免挤压和一般重写历史,除非您绝对必须。 微不足道的提交并不是压制提交提交的理由。如果他们能留下来,让他们留下来。重写历史在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.