I'm looking for a git command to help me with my feature branches when they're ready to go into Master. This git command would squash all my changes on my branch into a single commit on top of master. I do this today with:
git rebase origin/master
git rebase -i HEAD~4
git log HEAD...origin/master
All you have to do is:
git checkout feature_branch git rebase master git checkout master git merge --squash feature_branch
As the docs for
git merge --squash say:
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 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).
After that, you can
git commit your changes which are already staged.