r/git • u/TachikawaKan5241 • 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
View all comments
Show parent comment
1
u/themule71 5h ago
Yeah u/kpg_on_ao3 seems to have missed the "rebase & squash" part. That's what leaves the history "clean".
Only on demos or very simple apps the units of work are small enough to be truly independent... in real, complex cases there can be multiple moving parts (think backend, frontend, APIs), often multiple developing teams, all working on the same feature. One can complete via stubs. One implementation may need refactoring later due to performance reasons that are not evident until all pieces are put together. Yet there can be a moment when "ok, our part is done for now, let the other teams see it", that doesn't mean it's the final implementation, it may turn out to be broken, incomplete, sub-optimal, etc.
A commit, even push to a wip branch, is something I want others to see, broken or not I don't know yet.
As I wrote in another comment, you final git history should be as clean as possible to enable git bisec.