Merge (with squash) all changes from another branch as a single commit
Found it! Merge command has a --squash
option
git checkout master
git merge --squash WIP
at this point everything is merged, possibly conflicted, but not committed. So I can now:
git add .
# git add -u # might be preferable, see below
git commit -m "Merged WIP"
Another option is git merge --squash <feature branch>
then finally do a git commit
.
From Git merge
--squash
--no-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 nextgit 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).