Git merge flattening

Verhogen picture Verhogen · Apr 24, 2009 · Viewed 39.1k times · Source

If I am working in multiple branches on a single feature, I use git pull branch1 branch2 branch3 to pull all the changes into my master branch. However, all the commit logs of each branch are copied as well. How do I flatten the commit log down to a single message?

Answer

Jakub Narębski picture Jakub Narębski · Apr 24, 2009

"git merge --squash" (after "git fetch"; "git pull" is just fetch+merge, pehaps it also allows --squash option) might be what you want.

From git-merge(1):

--squash

Produce the working tree and index state as if a real merge happened, 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).