devanthe.dev

View Diff In Git Commit

1 min read

1git commit -v

When you commit using the -v flag a diff of files that are staged is appended to the end of the editor you use when writing commit messages. The best part is this diff is not appended to the actual commit message!

Here is an example where I commited this blog post!

1Add post about -v arg when commiting.
2# Please enter the commit message for your changes. Lines starting
3# with '#' will be ignored, and an empty message aborts the commit.
4#
5# On branch master
6# Your branch is up to date with 'origin/master'.
7#
8# Changes to be committed:
9# new file: site/content/blog/2019-01-31-view-diff-in-git-commit.md
10#
11# ------------------------ >8 ------------------------
12# Do not modify or remove the line above.
13# Everything below it will be ignored.
14diff --git a/site/content/blog/2019-01-31-view-diff-in-git-commit.md b/site/content/blog/2019-01-31-view-diff-in-git-commit.md
15new file mode 100644
16index 0000000..40662f3
17--- /dev/null
18+++ b/site/content/blog/2019-01-31-view-diff-in-git-commit.md
19@@ -0,0 +1,15 @@
20+---
21+date: 2019-01-31
22+title: 'View Diff In Git Commit'
23+description: 'Ever need to see a diff while building a commit message?'
24+published: true
25+spoiler: 'Ever need to see a diff while building a commit message?'
26+---
27+
28+```bash
29+git commit -v
30+```
31+
32+When you commit using the `-v` flag a diff of files that are staged is appended
33+to the end of the editor you use when writing commit messages. The best part is
34+this diff is not appended to the actual commit message!