I have a local branch, we're using git-flow with Pull Requests and I'm looking to squash a few commits after receiving PR feedback.
How can I squash all my commits (from PR's for example) into the same branch?
I imagine it would be something like:
git checkout master # For master
git pull # Get all branches up-to-date
git checkout feature1 # Checkout the branch
git checkout -b feature1_squash # Make a copy of the branch
git branch -D feature1 # Delete original branch
git checkout master # (?) Branch off latest master for safety
git checkout -b feature1 # Make new (empty) original branch
git merge --squash feature1_squash # Merge with squash into it
git push -f feature1 # Push, force will be required
but I'm not sure.
With that many steps it also seems like a good case for using a function to tie it all together and just pass the branch name as a parameter. Of course automating it would mean making sure to handle errors, exceptions, edge cases, etc.
I don't want to use interactive rebase because it's a little tricky to get right for newbies that I train. I also don't want to have to know the number of commits, I just want to do all the ones that exist on this branch.