←back to thread

362 points mmphosis | 1 comments | | HN request time: 0.199s | source
Show context
simonw ◴[] No.42165792[source]
On commit size:

> You just never know when you have to revert a particular change and there's a sense of bliss knowing where you introduced a bug six days ago and only reverting that commit without going through the savagery of merge conflicts.

This is key for me: a good shape to aim for with a commit is one that can be easily reverted.

replies(7): >>42165815 #>>42166356 #>>42166417 #>>42166427 #>>42166824 #>>42167218 #>>42167574 #
charles_f ◴[] No.42165815[source]
A trick to help doing that, when you start having multiple changes that could be distinct commits, use git add --patch to select the changes one by one. Not only that can allow you to create smaller changes, it also gives you an opportunity to review your code before you commit
replies(2): >>42165883 #>>42167379 #
JoshTriplett ◴[] No.42165883[source]
Agreed, but after decomposing the change into logical commits, doublecheck that the project builds after each commit.
replies(1): >>42165954 #
do_not_redeem ◴[] No.42165954[source]
Or even better, set up a pre-commit hook so that happens automatically.
replies(2): >>42166337 #>>42167243 #
keybored ◴[] No.42167243[source]
Stalling a commit for more than a third of a second is way too much.
replies(1): >>42167694 #
ervine ◴[] No.42167694[source]
Slightly-longer commits to have never-broken commits... hmmmmmm.
replies(2): >>42168168 #>>42170498 #
Izkata ◴[] No.42168168[source]
If you hit a full second, that's just right back to the svn days where there was just enough friction people wouldn't bother to commit until everything was completely done, then the commit would often be too big to easily describe why things were done in the commit message.
replies(2): >>42168174 #>>42168289 #
1. JoshTriplett ◴[] No.42168174[source]
I don't think taking one second to commit is a problem. However, verifying that software builds typically takes a lot longer than a second.