Danny Andrews
Sep 3, 2018 · 2 min read

In your example, I would still bring in the changes from master to feature using a merge, rather than rebasing feature onto master

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.

    Danny Andrews

    Written by

    Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
    Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
    Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade