Why can’t I use git merge –squash with –no-ff?

It probably doesn’t let you because such a command wouldn’t make sense.

The documentation for --squash says (emphasis mine):

–squash
Produce the working tree and index state as if a real merge happened (except for the merge information), but do not actually make a commit or move the HEAD, nor record GIT_DIR/MERGE_HEAD to cause the next git commit command to create a merge commit. This allows you to create a single commit on top of the current branch whose effect is the same as merging another branch (or more in case of an octopus).

The --no-ff flag does:

Create a merge commit even when the merge resolves as a fast-forward.

You are essentially asking git to make a commit and NOT make a commit at the same time.

If you want to preserve all of the history of your branch, you should use the --no-ff flag. Commit d is a merge commit that has two parents, a and c.

a ------ d -- ....
 \      /
  b -- c  

If you want all of the commits on that branch to be treated as a single unit of work, then use --squash. Commit d is a regular commit that contains all of the changes from commits b and c but has only one parent, a.

a ---- d -- ....
 \      
  b -- c  

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)