ITNEXT

ITNEXT is a platform for IT developers & software engineers to share knowledge, connect…

Follow publication

Member-only story

Git Commit Squash

Squashing commits is the act of combining a few commits into one. There are two places the term “squash” appears, in the context of git:

The squash merge is a special type of merging, that automatically takes all of the commits in one branch, squashes them together, and adds the result commit into the target branch (usually master).

Squash merge is partially addressed in the following issue of Git Weekly:

In this issue, we’re going to talk about the ways one squashes a few commits together manually.

Manual Squash

Manual squash is possible through “interactive rebasing”. Let’s assume we want to squash 5 last commits together. We’ll then do an interactive rebase on the last 5 commits:

git rebase -i HEAD~5

This command will start the interactive rebase. An editor (e.g. nano) with content similar to what follows will launch:

pick f72e7cb Feat: Resurrect flatMap
pick 1a18b1c Feat: Add list transformations
pick 3420af4 3.0.0
pick f55a9ee Docs: Add marble diagrams to README
pick 0433f9d Update README.md

Create an account to read the full story.

The author made this story available to Medium members only.
If you’re new to Medium, create a new account to read this story on us.

Or, continue in mobile web

Already have an account? Sign in

Published in ITNEXT

ITNEXT is a platform for IT developers & software engineers to share knowledge, connect, collaborate, learn and experience next-gen technologies.

Written by Mohammad-Ali A'RÂBI

Software Engineer at Haufe Akademie | Docker Captain | Content Creator

No responses yet

Write a response