Junk Drawer Logo Junk Drawer

For all those little papers scattered across your desk

What everyone should know about git commit

D. Ben Knoble on 02 Aug 2024 in Blog

These tips make it easier to write better commit messages.

  1. Stop using -m (configure a proper editor)
  2. Write while looking at the diff with -v

Stop using git commit -m

Using -m encourages short commit messages that don’t give meaningful information. Did you know that omitting -m gives you a chance to write your commit in your favorite editor? I think many people assume that -m is the only way to avoid being dropped in to Vi (oh, the horror… I guess…), but you can make Git use any editor you want. Now you have room to write those standard formatted commit messages.

The -m flag is convenient for wip-style save-my-progress commits that you’ll rebase and reword. You will reword them, won’t you?

Use -v to see your changes in the commit message template

You’re writing your commit message and you want to review the changes to make sure you commented on everything. What do you do?

See that last one? If you need to, turn on commit.verbose; then Git will include the diff in your commit message template for you to refer to.


Tags:

Categories: Blog

Load Comments
Previous Next
Back to posts