From 22e8e6c7a6e3c536f562ca6a8a0ffb4975dd71c9 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Sun, 27 Oct 2024 00:32:50 +0100 Subject: [PATCH] Add daily email for 2024-10-25 Always review your changes --- source/_daily_emails/2024-10-25.md | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 source/_daily_emails/2024-10-25.md diff --git a/source/_daily_emails/2024-10-25.md b/source/_daily_emails/2024-10-25.md new file mode 100644 index 00000000..fead7d6b --- /dev/null +++ b/source/_daily_emails/2024-10-25.md @@ -0,0 +1,29 @@ +--- +title: Always review your changes +date: 2024-10-25 +permalink: daily/2024/10/25/always-review-your-changes +tags: + - software-development + - git +cta: ~ +snippet: | + Always review your staged changes before committing. +--- + +[In yesterday's email][0] where I wrote about `git stash`, I mentioned the `-p` or `--patch` options. + +When stashing changes, this allows you to interactively select which changes you want to stash and what you don't. + +This is supported by other Git commands, including `git add`. + +I always use `git add -p` when adding changes as it gives me the chance to review them before committing them. + +If I left any stray comments, debug code, trailing spaces or anything I don't want to commit, I can remove them. + +If I was working on multiple changes (which I avoid), I can select the appropriate changes and create commits related to each change to keep the history clean and useful. + +I also use `git diff` and `git diff --staged` to review changes as well as `git show` to review commits. + +By doing this, I know my commits will be in the best state for others to review now or for me to review if I need to in the future. + +[0]: {{site.url}}/daily/2024/10/24/git-stash-is-underrated