Make your git commit verbose

#git Jul 24, 2016 1 min Mike Kowalski

Even if committing changes with git is straightforward, sometimes you want to verify all changes before doing it (e.g. to come up with with a nice and meaningfull commit message). Luckily there is --verbose switch for git commit. According to the manual (git commit --help):

-v, --verbose

Show unified diff between the HEAD commit and what would be committed at the bottom of the commit message template to help the user describe the commit by reminding what changes the commit has.

So when you type git commit -v you should see something like this:

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Your branch is up-to-date with 'origin/master'.
#
# Changes to be committed:
#       deleted:    scalastyle-config.xml
#
# Changes not staged for commit:
#       modified:   src/main/scala/net/mkowalski/sparkfim/cache/PersistenceManager.scala
#       modified:   src/main/scala/net/mkowalski/sparkfim/eclat/EclatLocalPrefixGroupMiner.scala
#
# ------------------------ >8 ------------------------
# Do not touch the line above.
# Everything below will be removed.
diff --git a/scalastyle-config.xml b/scalastyle-config.xml
deleted file mode 100644
index 7e3596f..0000000
--- a/scalastyle-config.xml
--- /dev/null
@@ -1,117 +0,0 @@
-<scalastyle>
- <name>Scalastyle standard configuration</name>
- <check level="warning" class="org.scalastyle.file.FileTabChecker" enabled="true"></check>
- <check level="warning" class="org.scalastyle.file.FileLengthChecker" enabled="true">
-  <parameters>
-   <parameter name="maxFileLength"><![CDATA[800]]></parameter>
-  </parameters>
- </check>

Quite nice, huh? Since Git 2.9 is out it’s now possible to configure this as a default behaviour for commit operation using:

git config −−global commit.verbose

Yet another reason for keeping git up-to-date :)

Mike Kowalski

Software engineer believing in craftsmanship and the power of fresh espresso. Writing in & about Java, distributed systems, and beyond. Mikes his own opinions and bytes.