I have a branch, mybranch, that has six commits and stems from commit C. I would like to create a new branch, also based on commit C, that effectively includes all the commits from mybranch, squashed into one commit. What’s the easiest way to do this?
I need to do this due to the mantra of “squash before you git-push”. For the new branch, I don’t want any mention of mybranch in the history pushed up to the remote server. The reason I want to create a whole new branch used to push is because I’d like to keep all the commits in mybranch for reference.
Why only push squashed commits? That sounds crazy (and wrong).
But to answer your question:
Another possibility would be to use
rebase -ito squash/fixup all commits into a single one:Also of interest is
git merge --squash: