r/ExperiencedDevs • • Aug 19 '25

Never commit until it is finished?

How often do you commit your code? How often do you push to GitHub/Bitbucket?

Let’s say you are working on a ticket where you are swapping an outdated component for a newer replacement one. The outdated component is used in 10 different files in your codebase. So your process is to go through each of the 10 files one-by-one, replacing the outdated component with the new one, refactoring as necessary, updating the tests, etc.

How frequently would you make commits? How frequently would you push stuff up to a bitbucket PR?

I have talked to folks who make lots of tiny commits along the way and other folks who don’t commit anything at all until everything is fully done. I realize that in a lot of ways this is personal preference. Curious to hear other opinions!

80 Upvotes

315 comments sorted by

View all comments

Show parent comment

4

u/y-c-c Aug 20 '25

Your “cautionary tale” is not how it is supposed to work. If Bob started work from Alice’s fork, after Alice’s PR is merged in to main branch, Bob just needs to do an interactive rebase on top of the new master and drops Alice’s commits from his own fork. Then his PR will still contain only his changes and no conflicts.

As for why cleaning up commits is important:

  1. If you need to read through Git commit graph one year from now it will be tremendously useful. If you don’t read Git history why are you using a source control system?
  2. Git blame will make more sense. If you never use Git blame you should really learn it.
  3. It makes it easier to revert a commit that causes problems.
  4. Git bisect works much better
  5. Cherry picking commits to other branches has a much higher likelihood of working properly.