Ask HN: How often do you commit / push in Git?
31–36 of 36 posts
Re: Ask HN: How often do you commit / push in Git?
#32I use feature branched for everything, usually named after an issue number. I created a script that allows me to commit whenever I get a task done, not the whole feature, and that script takes care of adding the files, committing them with a message, tags it with the issue number (current branch name), and pushes to remote. That way, every time I save, the changes are saved on the remote GIT repo in case my computer…
Just curious -- do you squash commits when merging one of these feature branches?
Re: Ask HN: How often do you commit / push in Git?
#33In general, I try to be very atomic. As an added benefit, this makes it simpler for someone doing a git bisect later.
Fixing minor typos or copy changes across a few files could result in several commits within 15 minutes.
Working on a major feature that requires research and definition and a lot of conversation or feedback, might mean a few commits over the span of a few days.
Re: Ask HN: How often do you commit / push in Git?
#34But seriously, I commit regularly, and rebase locally before pushing, whenever possible.
It's not really about how often you commit, it's about documenting that commit as a single unit of work so looking at it it's clear what you did, and why. This often requires planning ahead of time, and even possibly creating a separate branch just for off topic commits that you think of while working on the same file.
I'm not perfect though, it's okay not to be perfect.
Re: Ask HN: How often do you commit / push in Git?
#35Recipe for disaster. :p
> knew people who pushed / committed like every 30 seconds
Pushing and committing is completely different actions in the git world.
If it's a simple fix then I try to commit and push almost instantly. If it is a large piece of work that needs several days, then I "checkpoint" it by committing at least once/day.
But I try to never checkpoint by committing something that breaks the build or unit tests. Like if my work is rewriting module A to B, then my first commit would be to add module B, second to change all dependencies from A to B and lastly to delete module A from the repo.