Should You Make Lots of Small Commits or One Big Commit?

0
15
Asked By CodeCrafter99 On

I'm starting my first open source repository and I'm curious how others manage their commit strategies. I currently have around 120 commits, which feels like a lot compared to many other repos that seem to have only a few commits. My approach involves making frequent small commits, each with a note explaining the change. I'd love to hear your thoughts on two things: 1. How do you typically handle commits when working on projects? 2. What do you consider best practices for committing changes?

4 Answers

Answered By DevDude2021 On

Honestly, it depends on the project and your style. I usually commit when I finish a task or when I hit a good stopping point during development, making sure to keep my work stable.

Answered By CodeNerd42 On

There’s a lot of different styles, and each has its pros and cons. Personally, I commit freely on my feature branch and then do a squash merge when it’s ready for the main branch. This way, you keep things tidy, but still allow for lots of experimentation without cluttering the main history.

BranchKing9 -

Right! Working in a branch allows for flexibility while keeping `main` clean. It's a smart approach.

Answered By PixelPusher77 On

Totally agree! I try to make my commits meaningful and keep them focused on single changes. It makes tracking progress easier and helps with future debugging.

Answered By CommitMasterZ On

When working on a long-term branch, each commit should represent a stable and functional version of the project. It's crucial that you can revert to previous commits without issues. On branches meant for review, you can be a bit more relaxed, as those can be squashed into a single commit with a brief description before merging. This method keeps things organized and easy to understand for everyone.

DevOldie20 -

Exactly! I tend to make lots of small, potentially unstable commits while I’m experimenting. Once everything works, I squash them into a solid commit with passing tests for the `main` branch.

TechGuru45 -

That’s spot on! Each commit should ‘just work.’ It’s about keeping your history clean and manageable. People really appreciate it when reviewing your code.

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.