r/git • • 1d ago

How often should I commit my changes?

I am fairly new to programming and git and I was just wondering how often I should commit my changes both locally and to Github? I feel like I'm doing it to often

9 Upvotes

79 comments sorted by

View all comments

2

u/bigkahuna1uk 1d ago

This is not a git question really but a problem definition issue. If you’ve decomposed the solution you’re working on into many small discrete units of work, then the time for git commits naturally emerges when each unit is completed. If this doesn’t happen, the time for a commit becomes more subjective rather than objective. As a general rule I would commit at least after each milestone in a feature is complete whether that’s the whole feature or just a facet that allows one to determine what’s been completed and what is left to develop. You usually develop a good cadence and end up committing several times during the day.