Live data from Hacker News

Ask HN: How often do you commit / push in Git?

news.ycombinator.com

11–20 of 36 posts

Re: Ask HN: How often do you commit / push in Git?

#11
> I'll commit for small, incremental changes. Each commit is a semantic change to me- could be a small change applied in the same way across multiple files, or a larger change in a single file that does one thing. - jtfairbank

I agree with that but i'd add that i'll also commit at any stopping point. Need to leave for work? Commit. Need to go home ? commit. Doesn't matter how broken the code is at that point. I'll rebase the ugly commit away. Usually the ugly commit will have a message like "INTERIM COMMIT - REBASE ME"

I'll also happily push these ugly commits to a topic branch on a remote machine for backup purposes as long as I know that no-one else is working on that branch.

Re: Ask HN: How often do you commit / push in Git?

#12
Incrementally, every time I make a small but significant change. I treat it like a super-save, so I can get that latest slice of work back if the disk on my dev machine dies. (The dev machine is currently a Linode.)

30 seconds is too often. Once a day isn't often enough.

Re: Ask HN: How often do you commit / push in Git?

#13
I usually commit whenever I've done one thing that builds and is the smallest amount of change that is still a self-contained change. For example, changes to package scripts, the code and test cases all live as separate commits. The most important thing to do is to make sure no commit breaks the build and that the commits are small enough that someone can follow what they are doing when they're bisecting in the future.

Re: Ask HN: How often do you commit / push in Git?

#14
Commit amend for small changes.

New commit for new logical "part" of feature.

Rebase interactive when feature is "done" (in some way) to fix commit messages and squash some extraneous commits.

Push (as a branch in forked repo).

Sometimes I push before the feature is complete for backup/accountability purposes, but then I rebase anyway and push force the thing once it's done.

Re: Ask HN: How often do you commit / push in Git?

#15
When developing something new, I make tons of tiny work-in-progress commits, sometimes dozens in a day, and frequently go back and squash them with rebase into a logical flow of changes, once it's more clear what that logical flow really is. I keep my WIP branches around locally for a while so I can go back and dig out the experiments I made along the way.

I prefer this over trying to get every commit right the first time. I also feel there's a nice change of pace in the process of stepping back, looking over the previous work, and shaping it into something that communicates the ideas well to reviewers.

Re: Ask HN: How often do you commit / push in Git?

#17

I use Scrum and I usually commit about once an hour. More if I'm just bug-fixing or correcting typos or adding comments. Committing every 30 seconds seems like it would knock me out of my flow so often that I wouldn't get anything done. That being said, if I'm working in the same files as someone else, I'll commit every few minutes (and so will they) so that the amount of conflicts we're creating don't get out of han…

You could imagine some sort of IDE plugin that commits-and-pushes with automatic messages on every save, but god help you if your CI triggers on every push and your test suite is non-trivial.

Re: Ask HN: How often do you commit / push in Git?

#18

I use Scrum and I usually commit about once an hour. More if I'm just bug-fixing or correcting typos or adding comments. Committing every 30 seconds seems like it would knock me out of my flow so often that I wouldn't get anything done. That being said, if I'm working in the same files as someone else, I'll commit every few minutes (and so will they) so that the amount of conflicts we're creating don't get out of han…

You could imagine some sort of IDE plugin that commits-and-pushes with automatic messages on every save, but god help you if your CI triggers on every push and your test suite is non-trivial.

Haha, yeah that would be way too much CI. We use CodeShip for CI/CD and they let you add "--skip-ci" to the commit message to skip deployment for trivial stuff.
Post reply on HN