Hi, I’m Erika Rowland (a.k.a. erikareads). Hi, I’m Erika. I’m an Ops-shaped Software Engineer, Toolmaker, and Resilience Engineering fan. I like Elixir, Reading, and Design. She/Her. If you're looking for experienced talent, I would love to chat. Published on

Include Diff in Git Commit Editor

Running git commit with the --verbose flag allows me to include the diff that’s being applied by the commit inside the editor where I’m writing my commit message. This makes it easier for me to describe the changes that were being made, since I can scroll down in my editor to see themRead more in the documentation for git-commit.

Even though the lines aren’t prefixed with #, they are ignored by git-commit when submitting my commit message.

For example:

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch main
# Initial commit
# Changes to be committed:
#	new file:   hello.txt
# ------------------------ >8 ------------------------
# Do not modify or remove the line above.
# Everything below it will be ignored.
diff --git a/hello.txt b/hello.txt
new file mode 100644
index 0000000..3b18e51
--- /dev/null
+++ b/hello.txt
@@ -0,0 +1 @@
+hello world

This can be set to on by default in the config using commit.verbose = trueRead (a little) more in the docs here.

Or as it shows up in my global config:

	verbose = true