How can I squash to make deals between A and K in one lock Z

If I have a commit history like this:

ABC-------GHJK (master) \ / DEF 

how can I crush a commit between A and K into one commit Z:

 AZK (master) 

?

+4
source share
1 answer

First do:

 git rebase -i A 

This will show the list of commits in a text editor, starting with B and ending with K.
You will need to change the pick text before committing C, D, E, F, H and J to s or squash . Do not change pick before B or K. Note that there should be no commit G, because this is a merge commit.

Finally, save and exit the editor. This will begin a real reboot.

The result will be like this:

 AZK' (master) \ BC-------GHJK (no branch) \ / DEF 

A part that does not have a branch will eventually be deleted by garbage collection.

+2
source

All Articles