In your example, I would still bring in the changes from
mastertofeatureusing a merge, rather than rebasingfeatureontomaster
Here’s a very common scenario which illustrates the weakness of that approach.
*me working on a feature*
git commit -m 'Test one'
git commit -m 'wip'
git commit -m 'Fix linting error'
*meanwhile my coworker merges a change into master that I need*
git merge master
git commit -m 'Finish feature'
Now, I push my changes and open a pull request. These are the commits my review sees:
'Test one''wip''Fix linting error''Merge master into feature-branch''Finish feature'
They, understandably, ask you to clean that up, so you aren’t left with extraneous, distracting commits. But you can’t! Because you’ve already merged master into your branch! The only way to fix it is to create a new branch off master and manually cherry-pick your commits into it. And you may have to do this multiple times if you need to bring changes in from master. If I had just used rebase to get up to date with master, I could still go back and clean up my commits.
What usually happens, though, is that those garbage temp commits make it into master because people don’t want to hassle with making clear, atomic commits. This is why an article titled “Why you should stop using Git rebase” is probably going to lead a lot of people astray.
Your concerns about not using rebase to merge into the master branch are more justified, but even then, the problems you mention would be alleviated by devs taking more care in squashing their commits locally, so errors are easier to isolate. And yes, most feature or bug branches should be squashed into a single commit and merged into master. Then, if it goes bad, you simply revert that SHA.
In short: the problems you mention in this article are rooted in lack of discipline and knowledge. I’m not pretending to be a git master by any means, but I don’t think we should spurn a useful git feature just because its possible to misuse it.
git is so great because it makes it very easy to experiment. A productive git workflow usually involves making many small commits as you work through a problem. But if you don’t know how to use rebase, you can’t ever clean up the story your commits tell.
