Differences between Git merge --squash and --no-commit

GitMergeSquash

Git Problem Overview


As the title says, I am not really clear about the differences between a git merge --squash and a git merge --no-commit.

As far as I understand the help page for git merge, both commands would leave me in an updated working-tree, where it is still possible to edit and then to do a final commit (or multiple commits).

Could someone clarify the differences of those 2 options? When would I use one instead of the other?

Git Solutions


Solution 1 - Git

git merge --no-commit

This is just like a normal merge but doesn't create a merge-commit. This commit will be a merge commit: when you look at the history, your commit will appear as a normal merge.

git merge --squash

This will merge the changes into your working tree without creating a merge commit. When you commit the merged changes, it will look like a new "normal" commit on your branch: without a merge commit in the history. It's almost like you did a cherry-pick on all the merged changes.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionquaylarView Question on Stackoverflow
Solution 1 - GitralphtheninjaView Answer on Stackoverflow