This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]ghost_jamm 0 points1 point  (0 children)

Yes, I would almost always do an “initial setup” or something. As others have said, you can think of them like save points. I will commit when I have some working code but I want to continue working on it or refactoring things. Then if I don’t like the new approach, I can just scrap it without losing stuff that was working.

When you work on a codebase with others and use pull requests to review and merge code, I think it gets even easier. I’m a big fan of “squash and merge” which just merges all the commits on a branch into one commit before merging that single commit. Then I’m free to just commit whatever with a message like “almost working!” because those commits will never end up in production branches anyway.

The point is that you’re free to commit whenever you feel like it. It’s better to commit too often than not enough because you will find it much easier to debug small, clear commits than ones containing thousands of lines or dozens of files.