threads / discuss / 45451

Why "You cannot combine --squash with --no-ff" in git merge?

Subject: Why "You cannot combine --squash with --no-ff" in git merge?

## tl;dr

2 messages between Mar 21, 2017 and Mar 21, 2017.

replies: 1people: 1as markdown or json

Anatoly Borodin· Mar 21, 2017, 01:57 UTC · lore
Hi All,

the message "You cannot combine --squash with --no-ff" appeared in 2008, in the commit 1c7b76be7d620bbaf2e6b8417f04012326bbb9df ("Build in merge"). I don't understand the logic of this restriction.

Imagine, I have the following branches, where A is a master and B is a feature branch:

	A---B1---B2---B3---B4---B
`git checkout A && git merge --squash --no-ff B` says:
	fatal: You cannot combine --squash with --no-ff.
`git merge --squash --ff` will happily move the A ref to the B commit.
But what I want, and expect, is:
	A---B'
where B' has the same tree as B.

This can of course be done with `git rebase --interactive` and marking all commits for squash or fixup. But `git merge --squash` works with not-fastforwarding feature branch, why should it refuse to work in a fastforwarding case?

-- 
Mit freundlichen Grüßen,
Anatoly Borodin
Anatoly Borodin· Mar 21, 2017, 02:11 UTC · re: Anatoly Borodin · lore

Re: Why "You cannot combine --squash with --no-ff" in git merge?

Hi All,

I made a mistake in the previous message. I'm really sorry, I need to go have some sleep right now.

Anatoly Borodin <anatoly.borodin@gmail.com> wrote:
Show 7 quoted lines
> `git merge --squash --ff` will happily move the A ref to the B commit.
> 
> But what I want, and expect, is:
> 
>         A---B'
> 
> where B' has the same tree as B.
`git merge --squash --ff` WILL create A---B'.

But it's still unclear to me why `git merge --squash --no-ff` should fail instead of doing the same as `git merge --squash --ff` does. The error message and the documentation do not give any good reasons for it.

PS In my case, I set `merge.ff=false` and run just `git merge --squash`.
-- 
Mit freundlichen Grüßen,
Anatoly Borodin

← back to recent threads