How Often Should You Commit to GitHub?

Hi all,

Just curious about how often a developer should be committing their code to GitHub. Should they treat it like a version of a saved file? Even if the code is only partially completed they commit in order to not lose progress or rollback to an earlier save?

Or do they save only completed code and their revisions?

There’s no hard and fast rule, really it’s entirely up to you how much you push. For example, for my website I host it on Heroku and the way to deploy to the full site is by pushing the changes to a git page. Therefore I decide that I’m not going to push anything until I have a full change that I’m happy with, so as not to push something half finished live. However I could also push every time I saved if I wanted to, but it wouldn’t necessarily be the most helpful thing to do. I would say use it how you want to use it, but don’t go too overboard as it would get annoying writing the same 3 commands every 2 or 3 minutes.


Apologies as it might’ve been what you meant the first time around but I think you’ll find yourself doing a lot more commits than pushes unless you’re having to change workstation often. If you’re in a group just double check with them as to whether they’re OK with frequent pushes (this could vary a lot depending on their workflow).

If you meant commits then there are alternative ways to locally stage small changes (see Stash changes while keeping the changes in the working directory in Git - Stack Overflow for example) that don’t quite warrant a commit. Once again there’s no strict rule but you might raise a few eyebrows if you’re adding a few hundred commits to change something simple (chances are someone will have to squash them).

It might be worth thinking about this in the reverse, if you find you’ve made breaking changes you’ll likely be stepping backwards through commits to deal with it. Too many is a hassle and a waste, too few could make it harder to fix. If you are working in a group project try viewing what others have done to get an idea of their typical workflow; or, better still, just ask :slightly_smiling_face:.