kdb
kdb

Reputation: 4416

Squash in git rebase with "git merge --squash" style commit message?

When using git merge --squash, the commit messages will be pre-populated with a full git log of the merged commits; When using git rebase -i to squash commits, the commit message doesn't contain as much information.

Is it possible to get the same prepopulated commit message when rebasing?

Upvotes: 0

Views: 203

Answers (1)

kdb
kdb

Reputation: 4416

Instead of using the squash operator in the git rebase -i interface, we can use exec git merge --squash to get the intended effect. For example, instead of

pick 31988313 master
pick 42983473 first commit of squash
squash 231adf41 second commit of squash
...
squash e32b1fa4 last commit of squash
pick 1ad9e130 more commits

We can use

pick 31988313 master
drop 42983473 first commit of squash
drop 231adf41 second commit of squash
...
drop e32b1fa4 last commit of squash
exec git merge --squash e32b1fa4
pick 1ad9e130 more commits

The downside is that additional care has to be taken to not accidentally drop too many commits.

Upvotes: 1

Related Questions