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

35

u/just_here_for_place 1d ago

Whenever you feel like it, but at least after every meaningful increment.

9

u/Soggy_Writing_3912 advanced 1d ago

that being said, i would still strongly suggest a commit at the outermost of 4 hrs of work. in other words, if you have been at it for 4 hrs, and still don't have some meaningful state (by developers' definition, not business definition), then something else is wrong.

1

u/shozzlez 1d ago

Even if you don’t push to a remote branch ?

3

u/Soggy_Writing_3912 advanced 23h ago

treat the remote as a safety net in case the laptop gets corrupted, fluid spillage, theft, etc. In that case, how often would you push to remote so that you at least have a backup copy?

2

u/TagadaPouetPouet 1d ago

This is the most important. You can still rebase to squash or rework the commits, but in the end what really matters is having a list of meaningful commits.
A reviewer should be able to understand your work by reading the successive commit messages.