Skip to content

Comment on Show HN: Commit Comments – build commit messages in code comments

Comments

Presumably this is so you don't forget about a bunch of small changes when making a large commit. However, for me, right before I do a commit, I always do a diff to make sure what I'm about to commit is what I intended to, which has the nice side effect of seeing all the changes and reminding me for the commit message.

Is this not the common way most people commit?

That's certainly how I do it. I find it very helpful to get a review of my changes, particularly before I begin on the next task.

I do a -p and work my way through all of the hunks, pulling out a cohesive "story" of multiple separate commits from the work that I did, sometimes editing hunks as I go to "backport" some changes to fit other parts of the story.

-p? Is this on git-commit, or something else?

git add -p

I believe this is a pretty common thing based on personal experience.

At this stage I also try to split up my changes into multiple commits, avoiding large commits.

I do that as well, but in my branch. When I merge to master I tend to squash into bigger commits so as not to pollute the timeline so much. If someone really needs to see the small commits they can always look at the branch.

I use SourceTree, which has the ability to stage individual lines (I know, git cli can as well). So even if I work on 2-3 things at the same time, it is trivial to select the correct changes for the commit.

I use git cola for the same. It's a really light weight little tool that's surprisingly feature complete.

I usually make a bunch of changes at once. Following a break I review the changes and break them up into logical commits.

I aim do break up changes so that the commit log can be read like a book and. I can guarantee that not a single commit contains hidden surprises or unrelated changes.

I don't know how most devs get by with just the CLI. A lightweight gui makes commits and reviewing the history tree so much easier.

That's how I do it as well. It's a personal code review.

Checkout the -v option :)

That doesn't seem to do anything for me. What am I looking for?

You want the -v option to git commit, not to git add.

git commit -v displays the patch below the message part you're writing, so that you can review the patch as you write the message.

AboutSource Built by g1lg1l

Hackerly is an independent reader for Hacker News, built on the public HN API. Not affiliated with Y Combinator.