简体   繁体   中英

“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. I haven't been able to find any examples that I could understand using 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.

There's a post at http://gitready.com/advanced/2009/02/10/squashing-commits-with-rebase.html that describes how to do this.

EDIT - Documentation for rebasing with TortoiseGit is at 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.

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)

If all of the commits are on one line, you could do this: "Combine to one commit"

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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