L&D series: Squash commits in Pull request or Merge request (before merge)
Learning and Development chapter 8.
10 commits is too much !!!
Well some of us may think like that and some of us is a PERFECTIONIST .
Before merge, actually we can combine those commits into a fewer commit. So, we can say a happy good bye to our Pull Request before merge into branch master.
A way to do it.
git checkout my_branch
git reset --soft HEAD~<amount>
git commit -m "my message"
git push --force origin my_branch
Another way to do it.
git rebase -i HEAD~<amount>
git rebase --interactive <commit-hash>
Simple, isn’t it ?!
Don’t worry, your PR/MR will still have the latest code that you’ve changed in your branch.
I don’t recommend this way after a pull request or merge request has created. But anyway it helped me a lot when I needed to test my automation in pipeline via code that had already pushed, so people not called me an idiot because so many commits I made. :D — MperMperPisang