diff --git a/README.md b/README.md index 12b3455..0007ef8 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/). For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1881 TILs and counting..._ +_1882 TILs and counting..._ See some of the other learning resources I work on: @@ -457,6 +457,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Stash Everything](git/stash-everything.md) - [Stashing Only Unstaged Changes](git/stashing-only-unstaged-changes.md) - [Stashing Untracked Files](git/stashing-untracked-files.md) +- [Summarize Amount Of Change For Specific Commit](git/summarize-amount-of-change-for-specific-commit.md) - [Switch To A Recent Branch With FZF](git/switch-to-a-recent-branch-with-fzf.md) - [Transition A Branch From One Base To Another](git/transition-a-branch-from-one-base-to-another.md) - [Turn Off The Output Pager For One Command](git/turn-off-the-output-pager-for-one-command.md) diff --git a/git/summarize-amount-of-change-for-specific-commit.md b/git/summarize-amount-of-change-for-specific-commit.md new file mode 100644 index 0000000..cfa2b70 --- /dev/null +++ b/git/summarize-amount-of-change-for-specific-commit.md @@ -0,0 +1,31 @@ +# Summarize Amount Of Change For Specific Commit + +To get a quick headline summary of the amount of change that happened in a +commit, I can use the `--shortstat` flag. This will sum up file changed, lines +added, and lines removed. This can be combined with an _empty_ format flag to +suppress all other output. + +I can run this for the latest commit on the current branch by referencing +`HEAD`. + +```bash +❯ git show --shortstat --format= HEAD + 3 files changed, 1046 insertions(+), 462 deletions(-) +``` + +Or I can point at some other commit via its SHA: + +```bash +❯ git show --shortstat --format= 8cbfcdd7 + 1 file changed, 238 insertions(+) +``` + +I can even summarize the amount of change for the entire feature branch I'm +working on by referencing a range between `main` and the `HEAD` commit. + +```bash +❯ git diff --shortstat main...HEAD + 36 files changed, 1125 insertions(+), 134 deletions(-) +``` + +See `man git-show` and `man git-diff` for more details.