git-squash man page

git-squash — Import changes from a branch


git-squash [<--squash-messages>] <source-branch|commit ref> [<commit-message>]


Produce the working tree and index state as if a real merge happened without the commit or merge marks.



Branch to squash on the current branch.

<commit reference> A commit reference (has to be from the current branch) can also be used as the first argument. A range of commits sha..HEAD will be squashed.


Commit the squash result with the concatenated squashed committed messages. This option can not be used together with <commit-message>.


If commit-message is given, commit the squash result.


$ git squash my-other-branch
Updating a2740f5..533b19c
Squash commit -- not updating HEAD
 my-changed-file | 1 +
 1 file changed, 1 insertion(+)
$ git commit -m "New commit without a real merge"

$ git squash HEAD~3 "Commit message"
$ git squash --squash-msg @~3


Written by Jesús Espino <>

Reporting Bugs


See Also


Referenced By


November 2019 Git Extras