简体   繁体   中英

Git: Squash commits in history keeping graph structure

I have a not yet published local repo with graph structure like this:

*   G 
*   F
|\
| * E
| * D
* | C: A minor fix -- SQUASHME  
* | B
|/
*   A

So I want to squash commits B and C into a single commit, keeping (I suspect it'll take recreating/rewriting commits to keep) this graph structure with its branching and merging points.

Any pointers?

git rebase -i A -p

then use fixup or squash stanza for C , depending on whether you want to use the commit message of B or want to edit it.

Note: Without the -p parameter the merges will be transformed into linear history.

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