简体   繁体   English

使用TortoiseGit的“ Flatten”提交历史记录

[英]“Flatten” Commit History using TortoiseGit

I have a bunch of commits to master that I would like to "flatten" into one big commit in order to reduce the repository size. 我有很多提交要掌握,我想将其“扁平化”为一个大提交,以减小存储库的大小。 I would like to do this using TortoiseGit. 我想使用TortoiseGit做到这一点。 I haven't been able to find any examples that I could understand using Tortoise... 我没有找到使用Tortoise可以理解的任何示例...

Also, doing this kind of thing is supposed to be a "no-no" for stuff that has been "shared". 同样,对于已经“共享”的东西,做这种事情应该是“不可以”。 I'm going to do this on something that I have pushed to a remote, however, I am the only one that has been doing anything with the remote and haven't created any branches over the history that I am trying to flatten. 我将在推送到某个远程服务器上执行此操作,但是,我是唯一一直使用该远程服务器执行过任何操作并且没有在我尝试压平的历史上创建任何分支的人员。 I assume this will not cause me any problems. 我认为这不会给我带来任何问题。

What you're referring to is called "squashing" commits, and can be done using the rebase command. 您所指的是“挤压”提交,可以使用rebase命令来完成。

There's a post at http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html that describes how to do this. http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html上有一篇文章介绍了如何执行此操作。

EDIT - Documentation for rebasing with TortoiseGit is at https://tortoisegit.org/docs/tortoisegit/tgit-dug-rebase.html 编辑-使用TortoiseGit进行基础调整的文档位于https://tortoisegit.org/docs/tortoisegit/tgit-dug-rebase.html

I personally think that Git is easier to understand if you use it from the command line, so it may be worth using the former link as a guide. 我个人认为,如果从命令行使用Git会更容易理解,因此使用前一个链接作为指南可能是值得的。

Regarding the remote repository, it shouldn't be an issue if no-one else is using it (that said, if you're going to edit your Git history, you should always aim to do so before pushing it to a remote server) 关于远程存储库,如果没有人使用它,这应该不是问题(也就是说,如果您要编辑Git历史记录,则应始终在将其推送到远程服务器之前进行编辑)

If all of the commits are on one line, you could do this: "Combine to one commit" 如果所有提交都在同一行上,则可以执行以下操作:“合并到一个提交”

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM