git checkout master
git merge --squash <feature>
would result in 1 squashed commit to master,
Correct.
but are the commits on the feature branch squashed?
No, or yes, or perhaps "mu": the question does not make sense. What the feature branch is, at this point, is effectively dead: it should not longer be used. What you have now can be drawn like this:
ABCD <-- master (HEAD)
/
...--*
\
A--B--C--D <-- feature
where ABCD
is a single commit that does the same thing as the four commit sequence A--B--C--D
. (Note that before the git merge --squash
, the name master
pointed to commit *
.)
You can now point the feature branch to the new commit, using, e.g., git branch -f feature master
, giving:
ABCD <-- master (HEAD), feature
/
...--*
\
A--B--C--D [abandoned]
Note that if you instead use:
git checkout <feature>
git rebase -i master
and then change three of the four pick
commands to squash
, you have wiped out the old feature branch and created a new feature
branch and moved the name feature
to point to it, in much the same way. What's different is that the name master
still points to its original commit, and you're on the new feature
:
ABCD <-- feature (HEAD)
/
...--* <-- master
\
A--B--C--D [abandoned]
You can now git checkout master
and git merge --ff-only feature
to get the same result as with the earlier git merge --squash
method.
In both cases, if anyone else is using the old feature
branch, they must accommodate the abrupt change to feature
, which has moved such that the original four commits are no longer useful and should stop being used.